这是我的代码,但我无法填充我的字符串与用户放入的值。EditText get toString
我已经尝试了很多从其他网站的解决方案,但它不会工作。
package app.android.Mel
import android.app.Activity;
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;
import android.widget.Toast;
public class RedFlashlightActivity extends Activity {
private EditText text;
private TextView myRecord;
private Button myButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (EditText) findViewById(R.id.txtName);
myButton = (Button) this.findViewById(R.id.myButton);
myRecord = (TextView) findViewById(R.id.myRecord);
final String rec = text.getText().toString();
myButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
myRecord.setText(rec);
Toast.makeText(RedFlashlightActivity.this,rec, Toast.LENGTH_SHORT).show();
}
});
}
}
现在可以工作 – Dragster 2010-10-27 08:36:36