我有兩個活動是朋友和細節,朋友的活動是一個列表視圖與列表數據從我已經創建的數據庫填充,當列表項被點擊時,細節活動應該啓動並列表項目數據進行的細節活動和投入在編輯文本框的細節類從一個活動獲取數據到另一個
package com.rich.myfinal;
public class FriendsActivity extends Activity {
private CustomCursorAdapter customAdapter;
private PersonDataHelper databaseHelper;
private ListView listView;
private static final String TAG = FriendsActivity.class.getSimpleName();
/**
* Called when the activity is first created.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_friends);
databaseHelper = new PersonDataHelper(this);
listView = (ListView) findViewById(R.id.list_data);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d(TAG, "clicked on item: " + position);
Intent i = new Intent(getApplicationContext(), DetailsActivity.class);
startActivity(i);
}
});
// Database query can be a time consuming task ..
// so its safe to call database query in another thread
// Handler, will handle this stuff for you <img src="http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif?m=1129645325g" alt=":)" class="wp-smiley">
new Handler().post(new Runnable() {
@Override
public void run() {
customAdapter = new CustomCursorAdapter(FriendsActivity.this, databaseHelper.getAllData());
listView.setAdapter(customAdapter);
}
});
}
}
細節性低於
package com.rich.myfinal;
public class DetailsActivity extends Activity {
EditText details;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
details = (EditText) findViewById (R.id.details);
}
}
什麼是你面臨的問題? –
我需要代碼的幫助才能將數據複製到詳細信息活動 – Richmahnn
您可能已經搜索過。這個問題每天至少出現一次。這裏有一個例子,在這裏數百...讓我試試看它是一個例子,在這裏數百... http://stackoverflow.com/questions/4860811/how-to-transfer-data-from-one-activity-to-another?rq = 1 – Simon