Custom Adapter for List View

public class ListAdapter extends ArrayAdapter<Item> { private int resourceLayout; private Context mContext; public ListAdapter(Context context, int resource, List<Item> items) { super(context, resource, items); this.resourceLayout = resource; this.mContext = context; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi; vi = LayoutInflater.from(mContext); v … Read more

Android pass Fragment parameter instead of List into ListView [closed]

The problem is that you are passing a list as argument to replace() and it is expecting a Fragment as parameter. public abstract FragmentTransaction replace (int containerViewId, Fragment fragment) You have passed a list as an argument instead of passing a Fragment. Try passing ReceivedSMS ( which extends ListFragment) instead of ListSMS which is a … Read more

My app crashes when I click on listview

@Override public void onItemClick(AdapterView parent, View view, int position, long id) { if(position==0){ Intent intent = new Intent(MainActivity.this,login.class); startActivity(intent); } selectedItem(position); } The parameter to start activity is wrong. But still with that code, compiler shouldn’t allow you. Is it crash or compiler error?

Nothing is populated from ArrayList to ListView

You didn’t provide all classes so some classes are provided by me. Here you are: ChooseCategory.java: import java.util.ArrayList; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.ListActivity; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.widget.ArrayAdapter; import android.widget.ListView; public class ChooseCategory extends ListActivity { private ListView lv; ArrayAdapter<FoodStores> arrayAdapter; private static final String TAG = “XXX”; private … Read more