This is my Linear Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center_horizontal"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".16"
android:ems="10"
android:text="Rule" >
<requestFocus />
</AutoCompleteTextView>
<LinearLayout style="@style/verticallayout" >
<LinearLayout style="@style/verticallayout" >
<Button
android:id="@+id/b1"
style="@style/buttons"
android:layout_weight=".16"
android:text="Button 1" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll41"
style="@style/horizontallayouthidden" >
<TextView
android:id="@+id/t1"
style="@style/textview"
android:layout_weight="0.5" />
<TextView
android:id="@+id/tt1"
style="@style/textview"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/verticallayout" >
<LinearLayout style="@style/verticallayout" >
<Button
android:id="@+id/b2"
style="@style/buttons"
android:layout_weight=".16"
android:text="Button 2" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll42"
style="@style/horizontallayouthidden" >
<TextView
android:id="@+id/t2"
style="@style/textview"
android:layout_weight="0.5" />
<TextView
android:id="@+id/tt2"
style="@style/textview"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/verticallayout" >
<LinearLayout style="@style/verticallayout" >
<Button
android:id="@+id/b3"
style="@style/buttons"
android:layout_weight=".16"
android:text="Button 3" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll43"
style="@style/horizontallayouthidden" >
<TextView
android:id="@+id/t3"
style="@style/textview"
android:layout_weight="0.5" />
<TextView
android:id="@+id/tt3"
style="@style/textview"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/verticallayout" >
<LinearLayout style="@style/verticallayout" >
<Button
android:id="@+id/b4"
style="@style/buttons"
android:layout_weight=".16"
android:text="Button 4" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll44"
style="@style/horizontallayouthidden" >
<TextView
android:id="@+id/t4"
style="@style/textview"
android:layout_weight="0.5" />
<TextView
android:id="@+id/tt4"
style="@style/textview"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/verticallayout" >
<LinearLayout style="@style/verticallayout" >
<Button
android:id="@+id/b5"
style="@style/buttons"
android:layout_weight=".16"
android:text="Button 5" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll45"
style="@style/horizontallayouthidden" >
<TextView
android:id="@+id/t5"
style="@style/textview"
android:layout_weight="0.5" />
<TextView
android:id="@+id/tt5"
style="@style/textview"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:enabled="false"
android:text="Prev" />
<Button
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:text="Next" />
</LinearLayout>
And this is my java Class
public void onClick(View arg0) {
String a=null;
switch(arg0.getId()){
case R.id.left:
Toast.makeText(getApplicationContext(), "Prev"+ count, Toast.LENGTH_LONG).show();
if( count==0)
prev.setEnabled(false);
else{
count--;
Toast.makeText(getApplicationContext(), "Prev", Toast.LENGTH_LONG).show();
}
break;
case R.id.right:
Toast.makeText(getApplicationContext(), "Prev"+ count, Toast.LENGTH_LONG).show();
if( count>((abc.size()/5)))
next.setEnabled(false);
else{
count++;
onClick(arg0);
}
break;
case R.id.b1:
t41.setText("t1");
tt41.setText("tt1");
a=abc.get(( count*0)+0)+"";
bb1.setText(a);
}
break;
case R.id.b2:
t42.setText("t1");
tt42.setText("tt1");
a=abc.get(( count*0)+1)+"";
bb2.setText(a);
}
break;
case R.id.b3:
t43.setText("t1");
tt43.setText("tt1");
a=abc.get(( count*0)+2)+"";
bb3.setText(a);
}
break;
case R.id.b4:
t44.setText("t1");
tt44.setText("tt1");
a=abc.get((count*0)+3)+"";
bb4.setText(a);
}
break;
case R.id.b5:
t45.setText("t1");
tt45.setText("tt1");
a=abc.get((count*0)+4)+"";
bb5.setText(a);
}
break;
}
}
Now i want to change the text of button when i click the next and prev button dynamicaaly from a list that is available in list "abc". The count is STATIC variable in an other class. When i click the values are not changing in the button. Could anyone please help me out with this issue..
in your xml use this code wherever you want to call onClick() method
for ex:
You have not set onClick listeners to the buttons.
There are no views with id either "left" or "right"
In your xml give onClick attribute field to both buttons
I guess that will solve your problem.