Android: difficulties referencing resources -


i'm still newbie android programming, tried tutorial create music app. @ stage in tutorial asked create new class extends base adapter , @ point in new class asked use layout inflater to inflate secondary layout, created. problem new class created when try inflating or referencing resource element @ all, errors. question : 1. impossible refer resources classes create ? 2. there error in ide(eclipse) or java thing. here's secondary layout xml file , class created. java lines * have errors. when inflating "r.layout.song","r.id.song_artist" , "r.id.song_title"

import android.r; import android.r.*; import android.view.view; import android.view.viewgroup; import android.widget.baseadapter; import android.content.context; import android.view.layoutinflater; import android.widget.linearlayout; import android.widget.textview; import java.util.arraylist;  public class songadapter extends baseadapter {  private arraylist<song> songs; private layoutinflater songinf;  public songadapter(context c, arraylist<song>thesongs){     songs = thesongs;     songinf = layoutinflater.from(c); }  @override public int getcount() {     // todo auto-generated method stub     return songs.size(); }  @override public object getitem(int arg0) {     // todo auto-generated method stub     return null; }  @override public long getitemid(int arg0) {     // todo auto-generated method stub     return 0; }  @override public view getview(int position, view convertview, viewgroup parent) {     linearlayout songlay = (linearlayout) songinf.inflate(r.layout.song,parent,false);*     textview songview = (textview)songlay.findviewbyid(r.id.song_title);*     textview artistview = (textview)songlay.findviewbyid(r.id.song_artist);*     song currsong = songs.get(position);     songview.settext(currsong.gettitle());     artistview.settext(currsong.getartist());     songlay.settag(position);     return songlay; }  } 

the xml file

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="5dp" android:onclick="songpicked" >  <textview     android:id="@+id/song_title"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:textcolor="#ffffff99"     android:textsize="20sp"     android:textstyle="bold"/>  <textview     android:id="@+id/song_artist"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:textcolor="#ffffff99"     android:textsize="18sp"     android:textstyle="italic"/>   </linearlayout> 

the error description reads "description resource path location type song_artist cannot resolved or not field song cannot resolved or not field
line 46 java problem song_title cannot resolved or not field

"

thanks in advance.

what r pointing @ in code?

it should point @ your.package.name.r. if pointing android.r, won't work. remove import android.r , import android.r.*, should ok.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -