活动可以对自己有意图吗?我创建了一个活动,它被称为activity_beautician_profile。此活动有一个编辑按钮,用户可以编辑他们的个人资料。因此,我计划首先禁用EditText,然后在用户单击编辑按钮时启用它。
我添加了一个android:onClick =" onClick"在编辑按钮中已经
到目前为止,这是我的代码:
public class BeauticianProfile extends AppCompatActivity {
Button btnedit;
EditText t1, t2, t3;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_beautician_profile);
final EditText t1 = (EditText) findViewById(R.id.name);
final EditText t2 = (EditText) findViewById(R.id.address);
final EditText t3 = (EditText) findViewById(R.id.email);
final EditText t4 = (EditText) findViewById(R.id.gender);
//so that i can pass my values from the sign-Up page to this page
t1.setText(getIntent().getExtras().getString("name"));
t2.setText(getIntent().getExtras().getString("mobile"));
t3.setText(getIntent().getExtras().getString("email"));
t4.setText(getIntent().getExtras().getString("gender"));
}
public void onClick (View v) {
if (v.getId() == btnedit.getId()) {
t1.setFocusable(true);
t2.setFocusable(true);
t3.setFocusable(true);
}
}
}
单击编辑按钮时,我的应用程序停止
答案 0 :(得分:1)
btnedit
为空,因为您尚未实现