android - Unable to make TextView visible -


am trying set textview element visible when click button. have set textview invisible , button in way:

<textview     android:id="@+id/textview2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/button1"     android:layout_below="@+id/button1"     android:layout_margintop="67dp"     android:text="textview"     android:visibility="invisible" />  <button     android:id="@+id/button2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbaseline="@+id/button1"     android:layout_alignbottom="@+id/button1"     android:layout_marginleft="19dp"     android:layout_torightof="@+id/radiogroup1"     android:text="solution" /> 

now setting textview visible after clicking button have written following java code:

button sl; textview tv; sl=(button)findviewbyid(r.id.button2);   tv=(textview)findviewbyid(r.id.textview2); sl.setonclicklistener(new view.onclicklistener() {      @override     public void onclick(view v) {         // todo auto-generated method stub         tv.setvisibility(view.visible);     } }); 

but after clicking button textview box not getting displayed.

edit: total code:

package com.example.aptitude;  import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.radiogroup; import android.widget.radiogroup.oncheckedchangelistener; import android.widget.textview;  public class quesone extends activity implements oncheckedchangelistener,onclicklistener{      radiogroup rg;     button bt,sl;     textview tv;     bundle b;     intent in;     @override     protected void oncreate(bundle savedinstancestate) {         // todo auto-generated method stub         super.oncreate(savedinstancestate);         setcontentview(r.layout.q1);         rg=(radiogroup)findviewbyid(r.id.radiogroup1);         bt=(button)findviewbyid(r.id.button1);         sl=(button)findviewbyid(r.id.button2);         tv=(textview)findviewbyid(r.id.textview2);         rg.setoncheckedchangelistener(this);         bt.setonclicklistener(this);         sl.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                 // todo auto-generated method stub                 tv.setvisibility(view.visible);             }         });      }     @override     public void oncheckedchanged(radiogroup group, int checkedid) {         // todo auto-generated method stub         b=new bundle();         in=new intent("com.example.aptitude.two");         int n=0;          switch(checkedid){             case r.id.radio0:                 n=0;                 b.putint("key", n);                 break;             case r.id.radio1:                 n=0;                 b.putint("key", n);                 break;             case r.id.radio2:                 n=0;                 b.putint("key", n);                 break;             case r.id.radio3:                 n++;                 b.putint("key", n);                 break;         }     }      @override     public void onclick(view v) {         // todo auto-generated method stub         in.putextras(b);         startactivity(in);     }   } 

xml file:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"      >      <textview         android:id="@+id/textview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true"         android:layout_marginleft="40dp"         android:layout_margintop="50dp"         android:textstyle="bold"         android:text="corpulent" />      <radiogroup         android:id="@+id/radiogroup1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignleft="@+id/textview1"         android:layout_below="@+id/textview1"         android:layout_margintop="27dp" >          <radiobutton             android:id="@+id/radio0"             android:layout_width="wrap_content"             android:layout_height="wrap_content"              android:text="lean" />          <radiobutton             android:id="@+id/radio1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="gaunt" />          <radiobutton             android:id="@+id/radio2"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="emaciated" />          <radiobutton             android:id="@+id/radio3"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="obese" />     </radiogroup>      <button         android:id="@+id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignright="@+id/textview1"         android:layout_below="@+id/radiogroup1"         android:layout_margintop="38dp"         android:text="next" />      <textview         android:id="@+id/textview2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignleft="@+id/button1"         android:layout_below="@+id/button1"         android:layout_margintop="67dp"         android:text="textview"         android:visibility="gone" />      <button         android:id="@+id/button2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignbaseline="@+id/button1"         android:layout_alignbottom="@+id/button1"         android:layout_marginleft="19dp"         android:layout_torightof="@+id/radiogroup1"         android:text="solution" />     </relativelayout> 

<textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/button1" android:layout_below="@+id/button1" android:text="textview" android:visibility="gone" /> 

try this


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -