Symbol not parsed error in activity file… here is a solution to the problem.
Symbol not parsed error in activity file
I’m trying to list all music files on an SD card using a ListView. In the Java code of the activity, an error occurred,
This is the method I use inside the class:
private void init_phone_music_grid() {
System.gc();
String[] proj = { MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Video.Media.SIZE };
musiccursor =
managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
proj, null, null, null);
count = musiccursor.getCount();
musiclist = (ListView)findViewById(R.id.sample);
musiclist.setAdapter(new MusicAdapter(getApplicationContext()));
musiclist.setOnItemClickListener(musicgridlistener);
mMediaPlayer = new MediaPlayer();
}
Now here are the simple troubles
musiclist = (ListView)findViewById(R.id.sample);
Android Studio says it can’t parse the symbol sample
.
But how is this possible when I define it explicitly in XML? This is the XML code:
<?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
< ListView
android:id="@+id/sample"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Looking for a solution!
Solution
Not sure if it will fix the problem, but your xml is malformed.
There
should not be any space signatures after <
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/sample"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>