The main disclaimer; I am new to programming mobile apps in general and Android in particular.
I have a button that, when clicked, should open the following operation:
bCustom.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(ctx, DiceCustomList.class); startActivity(i); } });
(where "private Context ctx = this;" because placing "this" where "ctx" does not get context when inside onClick)
The program crashes before the current activity is obscured (although I'm not sure how this affects the transition). After commenting on almost everything, here is the activity that it causes:
public class DiceCustomList extends ListActivity { @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.custom_list); } }
And custom_list.xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="@string/rollText" android:id="@+id/textRoll2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="11pt" android:gravity="center"/> <ListView android:layout_height="wrap_content" android:id="@+id/listView1" android:layout_width="fill_parent"/> </LinearLayout>
I think the problem is the button code, but I canβt get any closer to the answer.
Edit: android manifest file has:
<activity android:name=".DiceCustomList"></activity>
Edit 2: Ah, after finally finding where Eclipse hides the stack, he told me the following: βYour content should have a ListView whose id attribute isβ android.R.id.list β, which they actually mean β@ + id / android: list.β Well, that was interesting. (Edit3: By that I mean, that was the answer. Thanks for the tip.)