views:

91

answers:

3

Hello

I've a ListActivity with a ListView, onItemClick i start an Intent,

Oncreate of this Intent i make a getParent but it's null. if i do this.isChild() it's false.

mPostList.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    Intent IntentDiscution = new Intent(parent.getContext(), EcrireMessage.class);
    ....
    IntentDiscution.putExtras(objetbunble);
    parentClass.startActivity(IntentDiscution); 
}
A: 

You probably looking for

YourParentClassName.this

code

mPostList.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    Intent IntentDiscution = new Intent(YourParentClassName.this, EcrireMessage.class);
    ....
    IntentDiscution.putExtras(objetbunble);
    parentClass.startActivity(IntentDiscution); 
}
Pentium10
i've this error : "No enclosing instance of the type List is accessible in scope"
NSchubhan
Post your entire file, as something else might be wrong there
Pentium10
+2  A: 

As far as I can tell, the only thing that can have a child Activity is an ActivityGroup.

Take a look at this discussion thread for more details: http://groups.google.com/group/android-beginners/browse_thread/thread/1ed4648486b6af64/

kiswa
A: 

Hi NSchubhan, Are you able to load activity from ListActivity onItemClicked event ? If yes please put code of that. I am not able to achive this, please help me.

vijaybsalunke