• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with a ListActivity, activity crashes

Mattimus

Lurker
Hi guys, if someone could give me a hand that would be great -

The program crashes when this activity is initiated and i'm not sure why. When all the functions are gone except the

public class DetailForm extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_form);
}
}

the activity gets a force close. when i change the EXTENDS command from LISTActivity to => Activity it will load... but not as a ListActivity

any thoughts?
 
Hi guys, if someone could give me a hand that would be great -

The program crashes when this activity is initiated and i'm not sure why. When all the functions are gone except the

public class DetailForm extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_form);
}
}

the activity gets a force close. when i change the EXTENDS command from LISTActivity to => Activity it will load... but not as a ListActivity

any thoughts?

Does your detail_form.xml layout file contain a ListView?
 
yes, the XML file detail_form.xml is as follows:


<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/blankbakgrnd"
>


<ListView
android:id="@+id/subjects"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"

/>


</LinearLayout>
 
I think that if you have an empty option in the xml then you won't need to set the adapter first.
 
Guys!! I am stuck with the same problem...I have to use ListView in my project. If I use only list view without setting the content view, it works. But I have to use but simultaneously


public class StudentActivity extends ListActivity
{


String[] name = {"pen", "Lighter", "Chair"};

EditText txtList,txtName;
int i=0;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(StudentActivity.this, android.R.layout.simple_expandable_list_item_1,name));
setContentView(R.layout.main);
txtName = (EditText) findViewById(R.id.txtName);

}


}


Please Suggest Something...
 
I think the reason for your crash is that when you extend your activity to ListActivity, then your ListView in the xml file needs to have a special Android id for the ListActivity to recognize it:
Code:
android:id="@+id/android:list"
 
Back
Top Bottom