I want to design an app in which there will be two buttons. And when we are pressing on each button one by one, it will show a list of some content.
For this, I am using the following code:
this.findViewById( R.id.UpdateList ).setOnClickListener( this );
this.findViewById( R.id.SettingsList ).setOnClickListener(buttonclicked);
With this i am creating butttons. For on click, I am using:
ArrayList<String> smsList = new ArrayList<String>();
public void onClick( View v ) {
//My list content for first button
}
private OnClickListener buttonclicked = new OnClickListener() {
public void onClick( View v ) {
//My list content for second button
}
ListView settingsListView = (ListView) findViewById( R.id.SETTINGSList );
settingsListView.setAdapter( new ArrayAdapter<String>( (Context) buttonclicked , android.R.layout.simple_list_item_1, settingsList) );
but the problem is my first list is working fine but when the second button is pressed,it stopped forcefully.
EDIT logcat:
05-13 19:44:46.988: E/AndroidRuntime(6806): FATAL EXCEPTION: main
05-13 19:44:46.988: E/AndroidRuntime(6806): java.lang.ClassCastException: com.bitgriff.androidcalls.MainActivity$1 cannot be cast to android.content.Context
05-13 19:44:46.988: E/AndroidRuntime(6806):atcom.bitgriff.androidcalls.MainActivity$1.onClick(MainAc??tivity.java:506)
05-13 19:44:46.988: E/AndroidRuntime(6806):atandroid.view.View.performClick(View.java:3627)
05-13 19:44:46.988: E/AndroidRuntime(6806):atandroid.view.View$PerformClick.run(View.java:14329) –