これは私の丸太猫です:
それは言うFatal Exception : Main
とres.resources
見つかりません、そして他の多くのエラー。どうしたの?
これが私の主な活動です:
public class MainActivity extends Activity {
private final static String highscore = "Your High Score : ";
private ListView listMenu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListMenu listMenuData[] = new ListMenu[]
{
new ListMenu(R.drawable.repetition, "Repetition\n" + highscore, 0)
};
ListMenuAdapter adapter = new ListMenuAdapter(this, R.layout.listmenu_item, listMenuData);
listMenu = (ListView)findViewById(R.id.listMenu);
View header = (View)getLayoutInflater().inflate(R.layout.listmenu_header, null);
listMenu.addHeaderView(header);
listMenu.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
これは、setter-getter の ListMenu です。
public class ListMenu {
public int icon, highscore;
public String title;
public ListMenu(){
super();
}
public ListMenu(int icon, String title, int highscore){
super();
this.icon = icon;
this.title = title;
this.highscore = highscore;
}
そして、これは私の ListMenuAdapter クラスです:
public class ListMenuAdapter extends ArrayAdapter<ListMenu> {
Context context;
int layoutResourceId;
ListMenu listmenu[] = null;
static class MenuHolder{
ImageView imgMenuIcon;
TextView txtTitle, txtHighScore;
}
public ListMenuAdapter (Context context, int layoutResourceId, ListMenu[] listmenu){
super(context, layoutResourceId, listmenu);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.listmenu = listmenu;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View row = convertView;
MenuHolder holder = null;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new MenuHolder();
holder.imgMenuIcon = (ImageView)row.findViewById(R.id.imgMenuIcon);
holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
holder.txtHighScore = (TextView)row.findViewById(R.id.txtHighScore);
row.setTag(holder);
}
else holder = (MenuHolder)row.getTag();
ListMenu menu = listmenu[position];
holder.imgMenuIcon.setImageResource(menu.icon);
holder.txtTitle.setText(menu.title);
holder.txtHighScore.setText(menu.highscore);
return row;
}
このチュートリアルのコードをたどって変更しました:ここをクリック
android.content.res.resources$NotFoundException
プロジェクトをクリーンアップする/Eclipseを再起動することでエラーを修正できると言う人もいますが、私にはうまくいきません
長い投稿で申し訳ありませんが、今何をすべきか本当にわかりません ありがとう:D