リストビューをクリックして新しいアクティビティを渡すことができません。この問題を解決する方法を教えてください。
ここに私のコード
// set UI
setContentView(R.layout.show_permission);
//get list from background
show = getListView();
//object for permission list
permission_list = new ArrayList<HashMap<String,String>>();
// get uid from main activity
Intent i = getIntent();
uid = i.getStringExtra(TAG_UID);
// get data from background thread
new GetPermission().execute();
show.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
//getting item from list Item
String project_id = ((TextView) view.findViewById(R.id.report_id)).getText().toString(); <---error here
String project_name = ((TextView) view.findViewById(R.id.pro_name)).getText().toString();
Intent in = getIntent();
//send report_id to next activity
in.putExtra(TAG_PROJECT_ID, project_id);
in.putExtra(TAG_PROJECT_NAME, project_name);
in.putExtra(TAG_UID, uid);
setResult(100, in);
finish();
}
});
そしてここで猫の表示をログに記録します
09-25 15:41:27.510: E/AndroidRuntime(1457): FATAL EXCEPTION: main
09-25 15:41:27.510: E/AndroidRuntime(1457): java.lang.NullPointerException
09-25 15:41:27.510: E/AndroidRuntime(1457): at com.example.androidhive.ProjectPermission$1.onItemClick(ProjectPermission.java:82)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.widget.AbsListView$1.run(AbsListView.java:3529)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.os.Handler.handleCallback(Handler.java:615)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.os.Handler.dispatchMessage(Handler.java:92)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.os.Looper.loop(Looper.java:137)
09-25 15:41:27.510: E/AndroidRuntime(1457): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-25 15:41:27.510: E/AndroidRuntime(1457): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 15:41:27.510: E/AndroidRuntime(1457): at java.lang.reflect.Method.invoke(Method.java:511)
09-25 15:41:27.510: E/AndroidRuntime(1457): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-25 15:41:27.510: E/AndroidRuntime(1457): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-25 15:41:27.510: E/AndroidRuntime(1457): at dalvik.system.NativeStart.main(Native Method)
手伝ってくれてありがとう!