protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_second);
final EditText editText2 = (EditText) findViewById(R.id.extraDetails);
final Intent intent = getIntent();
if(intent.hasExtra("details")){
String extra = intent.getStringExtra("details");
editText2.setText(extra);
}
else {
editText2.setText(blank);
}
Button SaveButton = (Button) findViewById(R.id.SaveButton);
SaveButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("details", editText2.getText());
Toast.makeText(SecondActivity.this, "Item Details saved!", Toast.LENGTH_LONG).show();
}
}
);
上一個活動是一個ListView,我有它設置,以便點擊一個特定的列表項時,它打開了一個活動的新實例,我試圖讓它如此用戶可以填寫一個EditText,並附加其他詳細信息,然後在未來點擊該特定項目時保存該信息。從建立意向按下按鈕時,Toast不會出現? (intents和listview)
代碼:
listView.setOnItemClickListener(
new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
IntentIndex="Intent"+position;
Intent IntentIndex = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(IntentIndex);
}
}
);
你可以添加你的詳細崩潰日誌跟蹤? –
'editText2.setText(blank);'。空白的價值是什麼? –
@john我之前聲明它爲「」 – Jamie