我從mainAcitivity與主佈局調用此方法SolveUpdation(從button-onclickAction監聽器)。我用其他的佈局,從用戶那裏獲取值,並將其設置爲主要佈局的按鈕標題和這只是不工作對我來說getText從一個佈局和(設置它)setText在另一個佈局
private void SolveUpdation() { //this function call is generated from the main Activity with main layout
setContentView(R.layout.updateappliance); //this is 2nd layout to get values from user and use them as buttonText in the main layout
btnSaveApp = (Button) findViewById(R.id.Bupdatenow);
btnSaveApp.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
mOutEditText = (EditText) findViewById(R.id.edit_text_1);
TextView view1 = (TextView) findViewById(R.id.edit_text_1);
final String TitleApp1 = view1.getText().toString(); //the value is read properly here
// if (App1.length() > 0) {
// byte[] send = App1.getBytes();
// }
btnSaveApp.setText(TitleApp1); //this works fine
startActivity(new Intent(HomeScreen.this, HomeScreen.class));//this the main activity for main layout
setContentView(R.layout.main); //this is the main layout and this instruction works
buttonLED1.setText(TitleApp1); //buttonLED1 (a Togglebutton or can be simple) is defined in main layout and this does not works and this is what i am stuck with
SaveAppNamesToast(TitleApp1); //this is just to toast the value and it works fine.
}});
所以PLZ任何一個可以指導我,爲什麼這個指令buttonLED1.setText指令(TitleApp1);不起作用?任何幫助將可升級..謝謝
我想你告訴的方式是我想到的一些方法,但是我並不瞭解這些具體的關鍵詞,因爲我是初學者。讓我試試這個......你很棒......謝謝你。 – AbdulSaleem