Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help to change the textview content on button click
    primarykey
    data
    text
    <p>This is my code. In this code I am trying to change the content of four text on a button click on first time and on same button click I am trying to change the content of only three textview. But it's not working.</p> <pre><code>public class Home_page_Activity extends Activity { Button next; int textids[]={R.id.text1,R.id.text2,R.id.text3,R.id.text4}; String Question[]={"1","2","3","4"}; String three[]={"7","27","37"}; TextView t1,t2,t3,t4,t5,t6,t7; int count=0; int check=0; //int button_id[]={R.id.next}; //Button btn[]; int test=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home_page_); t1=(TextView)findViewById(R.id.text1); t2=(TextView)findViewById(R.id.text2); t3=(TextView)findViewById(R.id.text3); t4=(TextView)findViewById(R.id.text4); t5=(TextView)findViewById(R.id.text5); t6=(TextView)findViewById(R.id.text6); t7=(TextView)findViewById(R.id.text7); next=(Button)findViewById(R.id.next); next.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if(test==1) { String get=(String) t1.getText(); //int inter=Integer.parseInt(get); Log.i("t1", get); t1.setText(""); t2.setText(""); t3.setText(""); t4.setText(""); threetext(); } nextquestion(); } }); } public void nextquestion() { t1.setText(Question[count]); t2.setText(Question[count+1]); t3.setText(Question[count+2]); t4.setText(Question[count+3]); Log.i("count", "value" +count); test++; } public void threetext() { Log.i("threetext", "working"); t1.setText(three[check]); t2.setText(three[check+1]); t3.setText(three[check+2]); t4.setText(""); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload