I used spinner sp which filled with SpinnerAdapter adapter and when run the app the spinner will be filled with the first item of Arraylist list witch contains img and text but when I click on the spinner the app stop and Android Monitor says that : Resource ID #0x7f0e00d5 type #0x12 is not valid
. I watched some cases similar to my case but didn't help and here is my code :
public class Serivce_Activity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_activity);
ArrayList<ItemData> list = new ArrayList<>();
list.add(new ItemData("tvsupport", R.drawable.com1_tvsupport));
list.add(new ItemData("refrigerator", R.drawable.com2_refrigerator));
list.add(new ItemData("wifi", R.drawable.com4_wifi));
list.add(new ItemData("plumbing", R.drawable.com5_plumbing));
Spinner sp = (Spinner) findViewById(R.id.request_spinner1);
SpinnerAdapter adapter = new SpinnerAdapter(this, R.layout.spinner_layout, R.id.txt, list);
sp.setAdapter(adapter);
}
}
This is SpinnerAdapter class :
class SpinnerAdapter extends ArrayAdapter<ItemData>{
private int groupid;
Activity context;
private ArrayList<ItemData> list;
private LayoutInflater inflater;
SpinnerAdapter(Activity context, int groupid, int id, ArrayList<ItemData> list){
super(context,id,list);
this.list=list;
inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.groupid=groupid;
}
#NonNull
public View getView(int position, View convertView, #NonNull ViewGroup parent){
View itemView=inflater.inflate(groupid,parent,false);
ImageView imageView=(ImageView)itemView.findViewById(R.id.img);
imageView.setImageResource(list.get(position).getImageId());
TextView textView=(TextView)itemView.findViewById(R.id.txt);
textView.setText(list.get(position).getText());
return itemView;
}
public View getDropDowenView(int position,View convertView,ViewGroup parent){
return getView(position,convertView,parent);
}
}
ItemData :
public class ItemData {
String text;
Integer imageId;
public ItemData(String text, Integer imageId) {
this.text = text;
this.imageId = imageId;
}
public String getText(){
return text;
}
public Integer getImageId(){
return imageId;
}
}
Spinner code :
<Spinner
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/request_spinner1"
android:layout_gravity="center"
>
</Spinner>
spinner_layout :
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/img"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:src="#drawable/com0_yourrequest" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/selection"
android:textColor="#2d5d13"
android:textSize="20sp" />
</LinearLayout>
In your spinner layout try removing this line
android:src="#drawable/com0_yourrequest"
I think this resource is missing. And check for other resources too if they are in your res folder or not also check names carefully.Hope it helps !
Check spellings here:
public View getDropDowenView(int position,View convertView,ViewGroup parent){ return getView(position,convertView,parent); }
and change spellings of getDropDowenView to getDropDownView
Related
So I have created a custom adapter for my ListView with three Views - TextView, ImageView and a basic View:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/AllNotesFragment">
<TextView
android:id="#+id/addNoteTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="30dp"
android:layout_marginTop="25dp"
android:textSize="18sp"
android:gravity="center"
android:fontFamily="#font/ukij_qolyazma"
android:text="+new"
/>
<ImageButton
android:id="#+id/deleteNoteImageButton"
android:layout_width="50dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="0dp"
android:layout_marginEnd="30dp"
android:textSize="24sp"
android:gravity="center"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:fontFamily="#font/ukij_qolyazma"
/>
<View
android:id="#+id/underlineView"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="70dp"
android:background="#color/colorMainDark" />
<ListView
android:id="#+id/notesListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="75dp"
android:layout_marginBottom="0dp">
</ListView>
I have created and instantiated the ListView
notesListView = view.findViewById(R.id.notesListView);
And filled it with a bunch of my notes
notes = (ArrayList<Note>) db.getAllNotesForDay(NotesForDayActivity.getRememberDay(),
NotesForDayActivity.getRememberMonth(),
NotesForDayActivity.getRememberYear());
for (Note note : notes) {
noteTitles.add(note.getTitle());
}
NotesListAdapter adapter = new NotesListAdapter(((NotesForDayActivity) getActivity()).getContext(), notes);
notesListView.setAdapter(adapter);
With my custom adapter:
public class NotesListAdapter extends BaseAdapter {
private static final String TAG = "NotesListAdapter";
public static Context context;
private RelativeLayout notesListRelativeLayout;
private TextView noteTitleTextView;
private ImageView tickImage;
private View underlineView;
private List<Note> notes;
// !
private View listItemsView;
public NotesListAdapter(Context context, List<Note> notes) {
this.notes = notes;
this.context = context;
}
#Override
public int getCount() {
return NotesForDayActivity.getCountNotes();
}
#Override
public Object getItem(int position) {
return notes.get(position);
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
listItemsView = convertView;
if (listItemsView == null) {
listItemsView = LayoutInflater.from(NotesForDayActivity.context).inflate(R.layout.notes_list_layout, null);
}
underlineView = listItemsView.findViewById(R.id.underlineView);
notesListRelativeLayout = (RelativeLayout) listItemsView.findViewById(R.id.notesListRelativeLayout);
noteTitleTextView = (TextView) listItemsView.findViewById(R.id.noteTitleTextView);
tickImage = (ImageView) listItemsView.findViewById(R.id.tickImageView);
noteTitleTextView.setText(notes.get(position).getTitle());
return listItemsView;
}
I can access an item inside my ListView with a OnItemClickListener, but I do not know how to access a View inside that particular Item of my ListView.
So If I set my OnClick like this:
notesListView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
How can I reference one of the three Views in that item. For example I need to set the visibility of my imageview:
Any help is appreciated.
Try this, OnItemClickListener will return the view, so that you can get access through that view
notesListView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView tickImage = view.findViewById(R.id. tickImageView);
if(tickImage!=null){
tickImage.setVisibility(View.GONE);
}
}
});
I have a custom spinner with an ImageView and a TextView, however the return codes do not return either one of these values rather they return it as an object.
How do I get the drawable id or the textview string separately and not the object of the spinner?
Do I have to do it in my adapter, the spinner itself or other components trying to get the data?
Tq
Here is my Spinner XML code :
<?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="horizontal">
<ImageView
android:id="#+id/spinnerImage"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="5dp"
android:layout_weight="1"
android:src="#drawable/dark_red_square" /><!--Make sure image is present in Drawable folder-->
<TextView
android:id="#+id/spinnerText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="2"
android:textSize="14sp"
android:gravity="center"
android:text="Demo"
android:textColor="#000" />
</LinearLayout>
This spinner is in a fragment. Honestly I don't know what codes should I sample here for reference, but here's the custom adapter
public class CustomAdapter extends BaseAdapter {
Context context;
int flags[];
String[] countryNames;
LayoutInflater inflter;
public CustomAdapter(Context context, int[] flags, String[] countryNames, LayoutInflater inflter) {
this.context = context;
this.flags = flags;
this.countryNames = countryNames;
this.inflter = (LayoutInflater.from(context));
}
#Override
public int getCount() {
return flags.length;
}
#Override
public Object getItem(int position) {
return countryNames[position];
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = inflter.inflate(R.layout.spinner_item, null);
TextView spinnerText= convertView.findViewById(R.id.spinnerText);
ImageView spinnerImage = convertView.findViewById(R.id.spinnerImage);
spinnerText.setText(countryNames[position]);
spinnerImage.setImageResource(flags[position]);
return convertView;
}
}
This question already has answers here:
ListView not showing at all
(1 answer)
Null pointer Exception - findViewById()
(12 answers)
Closed 4 years ago.
I have a custom Adapter called MyAdapter where i'm trying to load a layout which supposedly should be inserted into a listview, but even when Android is not giving errors the view is showing in blank.
In the next screenshot, i show what i get after build my app.
What i'm expecting to load is my layout into my listview:
ListView
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragments.NewsFragment">
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</FrameLayout>
Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="#+id/list_item"
android:layout_height="80dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageabdcf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="25dp"
tools:srcCompat="#android:drawable/btn_star_big_on" />
<TextView
android:id="#+id/textabcdf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
NewsFragment.java
public class NewsFragment extends Fragment {
private ListView listView;
private List<String> names;
public NewsFragment() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_news, container, false);
listView = (ListView) v.findViewById(R.id.listView);
names = new ArrayList<String>();
names.add("Fernando");
names.add("Roberto");
names.add("Torres");
names.add("Urban");
ArrayAdapter<String> adapter = new ArrayAdapter<>(v.getContext(), android.R.layout.simple_list_item_1, names);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getView().getContext(), "Clicked: " + names.get(position), Toast.LENGTH_LONG).show();
}
});
MyAdapter myAdapter = new MyAdapter(v.getContext(), R.layout.card_view_news, names);
listView.setAdapter(myAdapter);
// Inflate the layout for this fragment
return v;
}
}
MyAdapter.java
public class MyAdapter extends BaseAdapter {
private Context context;
private int layout;
private List<String> names;
public MyAdapter(Context context, int layout, List<String> names) {
this.context = context;
this.layout = layout;
this.names = names;
}
#Override
public int getCount() {
return 0;
}
#Override
public Object getItem(int position) {
return this.names.get(position);
}
#Override
public long getItemId(int id) {
return id;
}
#Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
View v = convertView;
LayoutInflater layoutInflater = LayoutInflater.from(this.context);
v = layoutInflater.inflate(R.layout.fragment_news, null);
String currentName = names.get(position);
//currentName = (String) getItem(position);
TextView textView = (TextView) v.findViewById(R.id.textabcdf);
textView.setText(currentName);
return v;
}
}
And what i'm expecting for is something like:
I'm trying to get ArrayList with different variables that i'm getting from a database to display in a customized listview
this is the main xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View the balance sheet"
android:textSize="29sp"
android:id="#+id/view"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView">
</ListView>
</RelativeLayout>
this is the customized layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/description_names"
android:text="description"
android:layout_marginTop="25sp"
android:layout_marginLeft="15sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/values_names"
android:text="value"
android:layout_marginTop="25sp"
android:layout_marginLeft="105sp"/>
</RelativeLayout>
this is the adapter, i wanted both the ArrayLists from the main activity but it's not working
class CustomAdapter extends ArrayAdapter<String> {
CustomAdapter(#NonNull Context context, ArrayList<String> mDetails,ArrayList<String> mValues) {
super(context,R.layout.custom_layout ,mDetails);
}
#NonNull
#Override
public View getView(int position, #Nullable View convertView, #NonNull ViewGroup parent) {
LayoutInflater inflater=LayoutInflater.from(getContext());
View customView=inflater.inflate(R.layout.custom_layout,parent,false);
String details=getItem(position);
String values=getItem(position);
TextView description_names=(TextView)customView.findViewById(R.id.description_names);
TextView values_names=(TextView)customView.findViewById(R.id.values_names);
description_names.setText(details);
return customView;
}
}
main activity
ListView listvIew=(ListView)findViewById(R.id.listView);
final ArrayAdapter<String>array=new CustomAdapter(this,mDetails,mValues);
listvIew.setAdapter(array);
private ArrayList<String>mDetails=new ArrayList<>();
private ArrayList<String>mValues=new ArrayList<>();
V3Ref.addChildEventListener(new ChildEventListener() {
#Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String value=dataSnapshot.child("records").child("values").getValue(String.class);
Log.d(TAG, "onChildAdded: the value is"+value);
mDetails.add(value);
mValues.add(value);
array.notifyDataSetChanged();
}
i'm getting values from the database then putting them in ArrayLists then i'm trying to display them in a customized listview but it's not working when i try to use the second Arraylist
adapter calls from your main activity should be like,
CusatomeAdapter adapter;
adapter = new CusatomeAdapter(mActivity,mList1 ,mList2);
mListview.setAdapter(adapter);
here is your adapter calss
public class CusatomeAdapter extends BaseAdapter {
public ArrayList<String> mList1;
public ArrayList<String> mList2;
Activity activity;
public CusatomeAdapter(Activity activity,ArrayList<String> mList1 , ArrayList<String> mList2){
super();
this.activity = activity;
this.mList1 = mList1;
this.mList2 = mList2;
}
#Override
public int getCount() {
return mList1.size(); //give the size of list here
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
LayoutInflater inflater = activity.getLayoutInflater();
if (convertView == null) {
convertView = inflater.inflate(R.layout.row_detail, null);
holder = new ViewHolder();
holder.tv_detail = (TextView) convertView.findViewById(R.id.tv_detail);
//same way define another text view and set their value ..
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tv_detail.setText(mList1.get(position).toString());
return convertView;
}
private class ViewHolder {
TextView tv_detail;
}
}
I am quite new to Android and can't achieve this, been searching all day.
Layout I'm trying to create.
I have created the custom xml layout, I have found ways to add items on create, but I need the list to be empty and than when the button is pressed to add from a list.
This is the layout:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<ImageView
android:id="#+id/info_img_view"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:id="#+id/info_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<TextView
android:id="#+id/info_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="right"
/>
</TableRow>
I have a ListView in the main activity:
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
How do I go about this? I would appreciate it if someone can point me to a resource where I can learn what the code is actually doing, not the tutorials I find where I just copy and paste...
Thanks!
Edit, a bit more explanation of what I'm trying to achieve
I have 6 buttons. When a button is pressed it should add a list item with two textviews, and one image out of total three images.
So for instance if Button1 is pressed: Add list item > "Text one" "Text one" "imageTwoOfThree".
Than, if Button2 is pressed: Add list item on top > "Text two" "Text two" "imageTwoOfThree"
And so on... The text is hardcoded.
Here use this:
I have created a list with dummydata you can change the text and Image according to you
First create a class Data:
public class Data {
private String name,price;
private int imageId;
public Data(){}
public Data(String name,String price,int imageId){
this.name = name;
this.price = price;
this.imageId = imageId;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getImageId() {
return imageId;
}
public void setImageId(int imageId) {
this.imageId = imageId;
}
}
Then create a ListView Adapter to handle your data:
public class ListViewAdaptor extends RecyclerView.Adapter<ListViewAdaptor.MyViewHolder> {
private List<Data> mDataList;
public class MyViewHolder extends RecyclerView.ViewHolder{
public TextView name,price;
public ImageView imageView;
public MyViewHolder(View view){
super(view);
name = (TextView) view.findViewById(R.id.name);
price= (TextView) view.findViewById(R.id.price);
imageView = (ImageView) view.findViewById(R.id.image);
}
}
public ListViewAdaptor(List<Data> dataList){
this.mDataList = dataList;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_view_item, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Data data = mDataList.get(position);
holder.name.setText(data.getName());
holder.price.setText(data.getPrice());
holder.imageView.setImageResource(data.getImageId());
}
#Override
public int getItemCount() {
return mDataList.size();
}
}
layout for your list view items name it list_view_item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
android:id="#+id/image"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/name"
android:text="name"
android:gravity="center"
android:textSize="26sp"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/price"
android:text="price"
android:gravity="center"
android:textSize="26sp"
android:layout_weight="1"/>
</LinearLayout>
Then from your activity where you want to add listView add recyclerView in layout:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/recycler_view">
</android.support.v7.widget.RecyclerView>
Then use this recyclerview like this:
//I have called it from my MainActivity you can use it in whatever activity you'll like
public class MainActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private ListViewAdaptor mAdapter;
private List<Data> mDataList = new ArrayList<>();
private static final String TAG = "MainActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mAdapter = new ListViewAdaptor(mDataList);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter(mAdapter);
prepareList();
}
public void prepareList(){
Data data = new Data("Item1","Price1",R.drawable.star);
mDataList.add(data);
data = new Data("Item2","Price2",R.drawable.star);
mDataList.add(data);
data = new Data("Item3","Price3",R.drawable.star);
mDataList.add(data);
data = new Data("Item4","Price4",R.drawable.star);
mDataList.add(data);
data = new Data("Item5","Price5",R.drawable.star);
mDataList.add(data);
}
}
Hope this helps!!!
You will find lots of online resources for this. But let me put it in a brief way.
Assuming you want to store 2 textviews in one single row.
1. For each layout of the row, you will need to make a custom layout xml file and design your layout there.
Next, make a class which stores the data and returns the data through getters.
class Category {
private String categoryName;
private String categoryImageURL;
Category (String categoryName, String categoryImageUrl) {
this.categoryName = categoryName;
this.categoryImageURL = categoryImageUrl;
}
String getCategoryName () {
return categoryName;
}
String getCategoryImageURL () {
return categoryImageURL;
}
}
Now make a custom arrayadapter which will link the data and the layout.
Extend the arrayadapter class with the class you defined above.
private class categoryArrayAdapter extends ArrayAdapter<Category> {
private Context context;
private List<Category> categories;
public categoryArrayAdapter (Context context, int resource, ArrayList<Category> objects) {
super(context, resource, objects);
this.context = context;
this.categories = objects;
}
public View getView (int position, View convertView, ViewGroup parent) {
Category category = categories.get(position);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.category_row_view, null);
TextView categoryListRowText = (TextView) view.findViewById(R.id.categoryListRowText);
TextView categoryListRowImage = (TextView) view.findViewById(R.id.categoryListRowImage);
categoryListRowText.setText(category.getCategoryName());
categoryListRowImage.setText(category.getCategoryImageURL());
return view;
}
}
Finally link the adapter to your listview
ArrayAdapter<Category> adapter = new categoryArrayAdapter(this, 0, categories);
categoryListView.setAdapter(adapter);
Hope this answered you question.