0

画像とテキストを含むリストビューを配置しようとしています ここに私のコードがあります

package com.example.listview;

import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class Sira extends Activity {

    private List<Kisas> stories = new ArrayList<Kisas>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sira);
        //Generates ListItems
        //Ctrl+1 to create the method from here
        PopulateStories();
        //To Show Items in ListView
        PopulateListView();
    }

    private void PopulateStories() {
        stories.add(new Kisas("Said bn 3amer Al Jam7i",1999,R.drawable.user,"needling work"));
        stories.add(new Kisas("Abu Tal7a Al Ansari",1999,R.drawable.personal,"needling work"));
        stories.add(new Kisas("Al Bara2 bn Malek Al Ansari",1999,R.drawable.smile,"needling work"));
        stories.add(new Kisas("Abu Ayoub Al Ansari",1999,R.drawable.ic_launcher,"needling work"));    
    }

    private void PopulateListView() {
        ArrayAdapter<Kisas> arrayadapter = new MyListAdapter();//we named it mylistadapter
        ListView List= (ListView) findViewById(R.id.listView_Stories);
        List.setAdapter(arrayadapter);
    }

    private class MyListAdapter extends ArrayAdapter<Kisas>{
        public MyListAdapter() {
            super(Sira.this,
                R.layout.item_view,stories);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View item_View= convertView;

            if(item_View ==null){
                item_View = getLayoutInflater().inflate(R.layout.item_view, parent ,false); 
            }
            Kisas currentStory= stories.get(position);
            ImageView imageview= (ImageView) item_View.findViewById(R.id.item_Icon)  ;
            imageview.setImageResource(currentStory.getIconId());
            TextView makeText = (TextView) item_View.findViewById(R.id.item_textMake);
            makeText.setText(currentStory.getMake());
            TextView yearText = (TextView) item_View.findViewById(R.id.item_textYear);
            yearText.setText(""+ currentStory.getYear()); //Lezem 7awela la string
            TextView conditionText = (TextView) item_View.findViewById(R.id.item_textCondition);
            conditionText.setText(currentStory.getCondition());
            return item_View;
        }
    }
}

メソッド PopulateListView でエラーが発生しています

誰でも助けることができますか?

私が知っているのは、コードがこれらの行にあるということです:

private void PopulateListView() {
    ArrayAdapter<Kisas> arrayadapter = new MyListAdapter();//we named it mylistadapter
    ListView List= (ListView) findViewById(R.id.listView_Stories);
    List.setAdapter(arrayadapter);    
}

private class MyListAdapter extends ArrayAdapter<Kisas> {
    public MyListAdapter() {
        super(Sira.this, R.layout.item_view,stories);
    }
}

私はアンドロイドが初めてなので、次のビデオの手順に従いました: http://www.youtube.com/watch?v=WRANgDgM2Zg

4

1 に答える 1