嗯,我有這個問題,我想從一個活動(MenuMeals)更改爲另一個(EditarPersona),與我的問題的特殊事情是,我使用動態類MenuMeal從另一個活動獲取的數組。直到這一點,沒有問題。 當我試圖在列表視圖中選擇一個項目時,問題就出現了。我的想法是,列表視圖上的所有項目,點擊時轉到EditarPersona,無論如何,改變的是我添加的putExtra,它給出了我觸摸的那個位置,這是「PosicionPlatillo」的位置。 當我運行它時,它出現一個錯誤說(來自LogCat的錯誤) 任何想法發生了什麼?或者有關如何正確執行此操作的任何想法?我的ListView與動態數組並沒有改變活動
http://postimg.org/image/hmhm8mb1v/
代碼MenuMeals的:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent intentobtenido = getIntent();
Bundle _uso = intentobtenido.getExtras();
String[] valor = _uso.getStringArray("Comida");
setListAdapter(new ArrayAdapter<String>(MenuMeals.this,
android.R.layout.simple_list_item_1, valor));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
try{
Intent editar = new Intent(MenuMeals.this, EditarPersona.class);
editar.putExtra("PosicionPlatillo", position);
editar.putExtra("Type", 4);
startActivity(editar);
}
catch(Exception e)
{
Log.e("Diet Helper", "Exception", e);
}
}
}
清單:
<activity
android:name="com.albertoha94.apps.diethelper.MenuMeals"
android:label="@string/editarcomida"
android:screenOrientation="portrait" >
</activity>
是您在清單中定義的「EditarPersona」活動嗎? – Devrim
而不是張貼圖片,你應該複製你的日誌,並在這裏過去。 –