我的程序量變到質變的sposes改變BNAME到位置,但不會出於某種原因 我發送位置記錄Expeance這個waycase R.id.record_expeance:變量未從空
startActivity(new Intent(BudgetStart.this, RecordExpeance.class));
ex.changeName(position);
BudgetStart.this.finish();
break;
後,即應等於位置,但它reamains空林不知道這是否是因爲我啓動類新的或什麼,但我不能弄明白
package budget.app;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class RecordExpeance extends Activity implements OnClickListener
{
private String bname;
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.recordexpeance);
final BudgetDB entry = new BudgetDB(RecordExpeance.this);
EditText a =(EditText)findViewById(R.id.txtExpeance);
EditText b =(EditText)findViewById(R.id.txtEMomo);
TextView c =(TextView)findViewById(R.id.lblBudgetAmount);
TextView d =(TextView)findViewById(R.id.lblBudgetName);
d.setText(bname);
String bamount;
entry.open();
bamount = entry.getBamount(bname);
entry.close();
Button A = (Button)findViewById(R.id.btnFinish);
A.setOnClickListener(this);
}
public void onClick(View argo)
{
// TODO Auto-generated method stub
startActivity(new Intent(RecordExpeance.this, BudgetStart.class));
RecordExpeance.this.finish();
}
public void changeName(String position)
{
// TODO Auto-generated method stub
bname = position;
}
}
任何和所有幫助是極大appricheated
你不能做你想要做的事。 'R.id.record_expeance'只存在於您在第一個活動中加載的佈局中。即使您在第二個活動佈局中使用相同的ID創建了一個textview,它也會是*不同的* textview。該id只是當前加載佈局中視圖的索引。 – Simon