错误:Android资源链接失败 C:\ Users \ Bassel \ AndroidStudioProjects \ MyApplication \ app \ src \ main \ res \ layout \ activity_main.xml:31: 错误:资源可绘制/ abc(又名 com.example.myapplication:drawable / abc)找不到。错误:失败 链接文件资源。
在可绘制对象中应该添加的abc文件是什么,直到错误消失
文件MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClickAddName(View view) {
// Add a new student record
ContentValues values = new ContentValues();
values.put(StudentsProvider.NAME,
((EditText)findViewById(R.id.editText2)).getText().toString());
values.put(StudentsProvider.GRADE,
((EditText)findViewById(R.id.editText3)).getText().toString());
Uri uri = getContentResolver().insert(
StudentsProvider.CONTENT_URI, values);
Toast.makeText(getBaseContext(),
uri.toString(), Toast.LENGTH_LONG).show();
}
public void onClickRetrieveStudents(View view) {
// Retrieve student records
String URL = "content://com.example.MyApplication.StudentsProvider";
Uri students = Uri.parse(URL);
Cursor c = managedQuery(students, null, null, null, "name");
if (c.moveToFirst()) {
do{
Toast.makeText(this,
c.getString(c.getColumnIndex(StudentsProvider._ID)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.NAME)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.GRADE)),
Toast.LENGTH_SHORT).show();
} while (c.moveToNext());
}
}
}
答案 0 :(得分:0)
您没有任何问题 MainActivity.java
只需将图像 abc.png 放入您的可绘制文件夹中,否则删除该行
android:src="@drawable/abc"
并运行项目。