Error:android.content.res.Resources$NotFoundException: String resource ID #0x1
Error:android.content.res.Resources$NotFoundException: String resource ID #0x1
我收到一条错误消息,提示无法找到资源 ID 尝试跟踪问题代码似乎没问题
此区域包含我的 class,它使用下面的 xml 资源来显示所有必要的元素 谁能帮助告诉我为什么会出现这样的错误
@Bind(R.id.showfirstname)
MyEditText Myfirstname;
@Bind(R.id.showlastname)
MyEditText Mylastname;
@Bind(R.id.showEmail)
MyEditText Myemail;
@Bind(R.id.profilephone)
MyEditText Mytel;
private Source mDataSource = new Source(this);
Cursor userDataCursor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_profile);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
ButterKnife.bind(this);
mDataSource.open();
userDataCursor = mDataSource.selectUserData();
userDataCursor.moveToFirst();
Myfirstname.setText(userDataCursor.getColumnIndex("firstname"));
Myfirstname.setEnabled(false);
Mylastname.setText(userDataCursor.getColumnIndex("lastname"));
Mylastname.setEnabled(false);
Myemail.setText(userDataCursor.getColumnIndex("email"));
Myemail.setEnabled(false);
Mytel.setText(userDataCursor.getColumnIndex("tel"));
Mytel.setEnabled(false);
mDataSource.close();
}
getColumnIndex
方法不会为您提供该列的值。它只为您提供数据库中该列的索引。
你应该这样做:
userDataCursor.getString(userDataCursor.getColumnIndex("firstname"));
我收到一条错误消息,提示无法找到资源 ID 尝试跟踪问题代码似乎没问题
此区域包含我的 class,它使用下面的 xml 资源来显示所有必要的元素 谁能帮助告诉我为什么会出现这样的错误
@Bind(R.id.showfirstname)
MyEditText Myfirstname;
@Bind(R.id.showlastname)
MyEditText Mylastname;
@Bind(R.id.showEmail)
MyEditText Myemail;
@Bind(R.id.profilephone)
MyEditText Mytel;
private Source mDataSource = new Source(this);
Cursor userDataCursor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_profile);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
ButterKnife.bind(this);
mDataSource.open();
userDataCursor = mDataSource.selectUserData();
userDataCursor.moveToFirst();
Myfirstname.setText(userDataCursor.getColumnIndex("firstname"));
Myfirstname.setEnabled(false);
Mylastname.setText(userDataCursor.getColumnIndex("lastname"));
Mylastname.setEnabled(false);
Myemail.setText(userDataCursor.getColumnIndex("email"));
Myemail.setEnabled(false);
Mytel.setText(userDataCursor.getColumnIndex("tel"));
Mytel.setEnabled(false);
mDataSource.close();
}
getColumnIndex
方法不会为您提供该列的值。它只为您提供数据库中该列的索引。
你应该这样做:
userDataCursor.getString(userDataCursor.getColumnIndex("firstname"));