Here I am taking three ArrayList (EmpName, EmpID and EmpPhone).
In this, I am storing 5 data in each arraylist and after that I'm trying to show
all data on listview like in each row of list view there will be 3 data.but I'm not
getting exact output. Here my entire code...Please help... Thank you.
activity_main.xml
<ListView
android:id="#+id/main_listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
custom_checkbox.xml
<TextView
android:id="#+id/custom_empname_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/custom_empid_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/custom_empphone_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
MainActivity.java
public class MainActivity extends Activity {
ArrayList<String> EmpName;
ArrayList<String> EmpID;
ArrayList<String> EmpMobile;
void getEmpDetails() {
EmpName.add("Jhon");
EmpName.add("Joy");
EmpName.add("Jain");
EmpName.add("Jason");
EmpName.add("Joky");
EmpID.add("1001");
EmpID.add("1002");
EmpID.add("1003");
EmpID.add("1004");
EmpID.add("1005");
EmpMobile.add("8179789878");
EmpMobile.add("8179789478");
EmpMobile.add("8179789378");
EmpMobile.add("8179789278");
EmpMobile.add("8179789678");
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView list = (ListView)findViewById(R.id.main_listView1);
}
class ListAdapter extends BaseAdapter {
#Override
public int getCount() {
// TODO Auto-generated method stub
return EmpName.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 index, View v, ViewGroup vg) {
// TODO Auto-generated method stub
v = getLayoutInflater().inflate(R.layout.custom_checkbox, null);
TextView t1 = (TextView)v.findViewById(R.id.custom_empname_textView);
TextView t2 = (TextView)v.findViewById(R.id.custom_empid_textView);
TextView t3 = (TextView)v.findViewById(R.id.custom_empphone_textView);
EmpName = new ArrayList<String>();
EmpID = new ArrayList<String>();
EmpMobile = new ArrayList<String>();
getEmpDetails();
ArrayAdapter<String> a1 =
new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, EmpName);
ArrayAdapter<String> a2 =
new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, EmpID);
ArrayAdapter<String> a3 =
new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, EmpMobile);
t1.setText((CharSequence) a1);
t2.setText((CharSequence) a2);
t3.setText((CharSequence) a3);
return null;
}
}
}
Based on your questions and issues, I would suggest you below points:
Manage a single ArrayList:
Managing different ArrayLists for the same object would be hard to manage. Like you are managing 3 ArrayList for storing information of Employee. Instead, you should manage a single ArrayList where Employee is a class.
Get particular Employee object: You can get particular Employee object inside the getView() method by position.
You are creating ArrayAdapter inside getView() method of your custom adapter. Not required at all.
And your code requires so many changes, better you get any android book and learn Android programming well.
Your code will not work, because you are using adapter wrong (and not setting to ListView at all).
Unfortunately, your code needs too many changes (for example, you should change new object Employee, you should pass array of these objects to adapter and bing values of Employee to item views) for resolving it in my answer, so just read good tutorial about adapters and try to write this code again:
http://www.javacodegeeks.com/2013/09/android-listview-with-adapter-example.html
http://www.vogella.com/tutorials/AndroidListView/article.html
Hope it helps.
Related
I know similar questions had been asked here a couple of times, but none of them could help me with my problem, so I will just have to ask again.
What I have is an app that has a fragment that holds a ListView in the main activity and I used a PullableListView so that when I drag the ListView up, it will trigger the onLoadMore() callback method to load more data from the server. Once data loaded, the data will be saved to a SQLiteDB and then used by the ListView to show the updated data.
The is my PullableListViewFragment.java:
public class PullableListViewFragment extends Fragment implements
OnItemClickListener {
private ListView listView;
private PullToRefreshLayout ptrl;
private MissionDB mMissionDB;
private List<MissionEntity> mData;
private MissionListAdapter mAdapter;
/**
* Specify the exact mission that will be displayed in MissionDetailActivity
*/
private int mIndexOfMission;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View pullableLayout = inflater.inflate(R.layout.pullable_layout, container, false);
listView = (ListView) pullableLayout.findViewById(R.id.content_view);
listView.setDivider(null);
ptrl = (PullToRefreshLayout) pullableLayout.findViewById(R.id.refresh_view);
ptrl.setOnRefreshListener(new RefreshListener());
loadData();
Log.d(Constants.LOG_TAG, "onCreateView Called from PullableListViewFragment");
return pullableLayout;
}
/**
* Initialise ListView
*/
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mAdapter = new MissionListAdapter(getActivity(), mData);
listView.setAdapter(mAdapter);
listView.setOnItemClickListener(this);
mAdapter.notifyDataSetChanged();
Log.d(Constants.LOG_TAG, "onActivityCreated Called from PullableListViewFragment");
}
/**
* Load data from db
*/
private void loadData() {
mData = new ArrayList<>();
mMissionDB = MissionDB.getInstance(MyApplication.getContext());
mData = mMissionDB.loadMission();
}
/**
* OnItemClick event
*/
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Intent intent = new Intent(getActivity(), MissionDetailActivity.class);
mIndexOfMission = mData.get((int) id).getId();
intent.putExtra("Position", mIndexOfMission);
startActivity(intent);
}
}
And this is the RefreshListener.java:
public class RefreshListener implements PullToRefreshLayout.OnRefreshListener {
private MissionDB mMissionDB = MissionDB.getInstance(MyApplication.getContext());
#Override
public void onLoadMore(final PullToRefreshLayout pullToRefreshLayout) {
// LoadMore
new Handler() {
#Override
public void handleMessage(Message msg) {
/** When drag up, load more mission that is older and not out of date */
mMissionDB.open();
int id = mMissionDB.getMaxOrMinId("MIN");
final JSONObject oldMission = new JSONObject();
try {
oldMission.put("platform", "1");
oldMission.put("more", 0);
oldMission.put("id", id);
oldMission.put("size", 1);
} catch (JSONException e) {
e.printStackTrace();
}
Thread t = new Thread(new Runnable() {
#Override
public void run() {
HttpRequest.sendHttpRequest(Constants.PULLORDRAG_TO_LOAD_MISSION_URL, oldMission, new HttpCallbackListener() {
#Override
public void onFinish(String response) {
MissionEntity mMission = new MissionEntity();
/** Save new mission to mission database */
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray missionList = jsonObject.getJSONArray("taskList");
for (int i = 0; i < missionList.length(); i++) {
JSONObject mission = missionList.getJSONObject(i);
mMission.setId(mission.getInt("id"));
mMission.setDownloadUrl(mission.getString("appPath"));
mMission.setCreateTime(mission.getString("taskId"));
mMission.setImageUrl(mission.getString("appImg"));
mMission.setTitleName(mission.getString("appName"));
mMission.setRemainTime("Remain: 1d 11h 23m 36s");
mMission.setParticipant("135");
mMission.setCreator("Google");
mMission.setRequirement(mission.getString("description"));
mMission.setRewards("TODO");
mMission.setAttention("TODO");
mMission.setValidDate(mission.getString("deadline"));
mMission.setAccepted("0");
mMission.setCollected("0");
mMission.setAccomplished("0");
mMissionDB.saveMission(mMission);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
public void onError(Exception e) {
e.printStackTrace();
Log.e(Constants.LOG_TAG, "Error while loading more");
}
});
}
});
try {
t.start();
t.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
pullToRefreshLayout.loadmoreFinish(PullToRefreshLayout.SUCCEED);
//==================Update 1==================
ListView list = (ListView) pullToRefreshLayout.findViewById(R.id.content_view);
List<MissionEntity> missionList = mMissionDB.loadMission();
Log.d(Constants.LOG_TAG, "mission size" + missionList.size());
MissionListAdapter adapter = (MissionListAdapter) list.getAdapter();
adapter.setData(missionList);
adapter.notifyDataSetChanged();
list.setAdapter(adapter);
//==================Update 1==================
}
}.sendEmptyMessageDelayed(0, 1000);
}
}
The PullToRefreshLayout is a custom RelativeLayout that defined a inner interface OnRefreshListener that will be called once the onLoadMore() callback method is called.
The ListView I use in the Fragment is a PullableListView that implemented a Pullable interface that can drag up.
My Pullable.java:
public interface Pullable
{
/**
* If pull up is not needed, set canPullUp to false
*
* #return true if the View can pull up
*/
boolean canPullUp();
}
This is the fragment's layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f2f2f2"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<pulltorefresh.PullToRefreshLayout
android:id="#+id/refresh_view"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/refresh_head"/>
<!-- Supports all view that implemented the Pullable interface -->
<pulltorefresh.PullableListView
android:id="#+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<include layout="#layout/load_more"/>
</pulltorefresh.PullToRefreshLayout>
</LinearLayout>
The problem is when the data in the SQLiteDB is changed after the onLoadMore() method, the ListView in the fragment doesn't refresh itself unless I navigate to another fragment within the same main activity and then navigate back.
I tired all the ways I can find here and none of them help.
Could anyone tell me how can I make the ListView refresh itself when the data in the SQLiteDB changed.
[Update 1] I've added some code in the onLoadMore() callback, the size of the data remains the same after I get some data from the server, i think this is the problem why the ListVie is not refreshing, what's interesting is if I put a Thread.sleep(500) before mMission.loadMission() the size of the data is correct and everything is fine. Any idea why?
In onLoadMore method, you just only load data and save into database. After load data, you should update the data source of the adapter and call adapter.notifyDataSetChanged() to refresh the listview. or you can notify the fragment to reload data from database.
Make sure it get data when load more first. And I think your mMissionDB is changed indeed, but what about mData? Your adapter is use mData as datasource actually, so you should update mData, and call adapter.notifyDataSetChanged() to refresh the listview. Hope it can help you.
I'm currently trying to extend an example that I found on http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/.
I first extended this by creating an EditText to function as my search bar and then followed a few tutorials to implement the Filter function. What I'm trying to do is when a user inputs a text, if the section has matching text, return the section and all its sub-items. If a sub-item is searched return its section and the sub-item matching the constraint. My functions work when there is no sections however it does not work at all with the sections.
Help would be greatly appreciated.
main_list.xml
<RelativeLayout 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="com.myapplication">
<EditText
android:id="#+id/search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:drawableRight="#android:drawable/ic_menu_search"
android:hint="Search"
android:lines="1"
android:maxLines="1"
android:maxWidth="100dp"
android:minWidth="300dp"
android:singleLine="true"/>
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/search_text"/>
</RelativeLayout>
I then modified a bit of the main activity so that I can implement the search bar.
ListSample.java
public class ListSample extends Activity {
SeparatedListAdapter adapter;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main_list);
ListView listView = (ListView) findViewById(R.id.list_view);
EditText inputSearch = (EditText) findViewById(R.id.search_text);
List<String> america = new ArrayList<>();
america.add("Chicago");
america.add("Washington");
List<String> australia = new ArrayList<>();
australia.add("Sydney");
australia.add("Melbourne");
australia.add("Perth");
List<String> combined = new ArrayList<>();
combined.addAll(america);
combined.addAll(australia);
// create our list and custom adapter
adapter = new SeparatedListAdapter(this, combined);
adapter.addSection("America", new ArrayAdapter<String>(this,
R.layout.list_item, america));
adapter.addSection("Australia", new ArrayAdapter<String>(this,
R.layout.list_item, australia));
listView.setAdapter(adapter);
inputSearch.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s.toString());
}
#Override
public void afterTextChanged(Editable s) {
}
});
}
}
Filter fucntions
#Override
public Filter getFilter() {
if(filter == null){
filter = new dataFilter();
}
return filter;
}
private class dataFilter extends Filter{
#Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
constraint = constraint.toString().toLowerCase(Locale.getDefault());
ArrayList<String> filterList = new ArrayList<String>();
if(constraint != null && constraint.length() > 0){
for(int i =0; i < originalDataFilterList.size(); i++){
if(originalDataFilterList.get(i).toLowerCase().contains(constraint.toString().toLowerCase())){
filterList.add(originalDataFilterList.get(i));
}
}
results.count = filterList.size();
results.values = filterList;
} else {
results.count = originalDataFilterList.size();
results.values = originalDataFilterList;
}
return results;
}
#Override
protected void publishResults(CharSequence constraint, FilterResults results){
originalData = (ArrayList<String>)results.values;
notifyDataSetChanged();
}
}
Currently, your filter result is stored in the originalData array without sub-section information. The code did not modify the headers adapter and sections map which are stored separately in the SeparatedListAdapter, and thus no change would occur when you change the filter and call notifyDataSetChanged().
Instead of creating and passing the combined list to the SeparatedListAdapter, and use this 'flat' list for filtering, you may need to iterate on the sections map and its adapters during the filtering, store the filtering results, and then the getItem(), getCount(), getViewTypeCount(), getItemViewType(), isEnabled(), getView() and getItemId() methods need to be rewritten to take into account the result.
There are many ways to implement this. For example, to avoid re-creating the sections and headers arrays each time your filter changes, you can calculate and store a mapping of list view position to the appropriate header and subitem (by storing the offset for headers / adapter and position for subitems), for application by methods such as getItem() accordingly. You also need to calculate the total count (for retrieval by getCount()).
I'm building my first app based on material from http://javatechig.com/video/json-feed-reader-in-android.
Everything goes ok so far, but I found one bug with ListView elements, which I can not manage to resolve by myself :(
I have extended list_row_layout.xml by 2 fields:
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:text="komcie"
android:textSize="11sp"
android:id="#+id/loadComments"
android:layout_gravity="center|bottom"
android:background="#bbb"
android:layout_marginLeft="5dp"
android:enabled="true"
android:clickable="true"
android:onClick="clickedLoadComments"
android:elegantTextHeight="true"
android:layout_toRightOf="#id/thumbImage"
android:layout_below="#+id/content"
android:padding="1px" />
<ListView
android:id="#+id/comment_list"
android:layout_toRightOf="#id/thumbImage"
android:layout_below="#+id/content"
android:paddingTop="5dp"
android:layout_marginTop="0dp"
android:paddingLeft="5dp"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:cacheColorHint="#00000000"
android:dividerHeight="1dp"
android:focusable="false"
android:listSelector="#drawable/list_selector_flatcolor"
android:visibility="invisible" />
Button.android:onClick="clickedLoadComments" function load Json with elements into ListView/comment_list. It works quite fine. But if there are more elements than could be displayed on screen (~8 elements) there is a bug. Comments from clicked element are loaded into every 8th element in a ListView.
Some code:
public void clickedLoadComments(View v)
{
try {
View parent = (View)v.getParent();
ViewHolder t = (ViewHolder) parent.getTag();
if( parent != null ) {
this.loadCommentsForLeaf(parent);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
protected void loadCommentsForLeaf( View view )
{
String tmpUrl = "http://some.url.com/Ajax/LoadComments?lid=" + this.currentLeafInUse;
JSONObject commentsJson = this.getJSONFromUrl(tmpUrl);
this.parseJsonComments(commentsJson);
if( commentsJson != null )
this.updateCommentList(view);
}
public void updateCommentList( View view) {
commentListView = (ListView) view.findViewById(R.id.comment_list);
commentListView.setVisibility(View.VISIBLE);
CommentListAdapter cla = new CommentListAdapter(this, this.commentList.get(this.currentLeafInUse));
commentListView.setAdapter(cla);
// Set list height.
ViewGroup.LayoutParams params = commentListView.getLayoutParams();
params.height = setListViewHeightBasedOnItems(commentListView) + 20;
commentListView.setLayoutParams(params);
commentListView.requestLayout();
}
CustomListAdapter.java code is mostly the same as the one in tutorial.
I would really appreciate help as I have spent many hours figuring it out with not success :(
This is just a guess. You might post your Adapter code and your parseJsonComments also if this does not work.
The Cause:
The problem you are describing might be caused due to the recycling and the reusage of Views. Take a look at this image from http://android.amberfog.com
As you can see the 1. items is reused and becomes the 8. item after scrolling.
Let's assume that Item 1 has an OnClickListener which updates a Text of the item.
For example we set the text to "clicked" after the OnClickListener is triggered.
Because item 1 is reused to create item 8, item 8 will also display the text "clicked".
The Solution:
The usual way is to save all states/content in a List(or whatever) and update everything in the getView call. So if you want to update text:
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
...
holder.textView.setText(jsonTexts[position]);
...
return convertView;
}
And if you want to update an item just update the List in your Adapter which holds the content/JsonObjects(etc.) and call notifyDataSetChanged.
public void updateCommentList(JSONObject commentsJson, int position) {
// does not exist you might create something
//like that in your Adapter class
commentListAdapter.updateItem(commentsJson,position);
commentListAdapter.notifyDataSetChanged();
}
After i populate the listview i call this method:
private void registerClickCallback() {
ListView list = (ListView) findViewById(R.id.lv);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View viewClicked,
int position, long id) {
String xx = position+ ":" + id;
//then you can do what ever you want
}
});
}
I'm trying to do my first Spinner, and I have encountered some difficulties, such as that I don't know if I can get an option by spinner.getSelectItem == "some string".
Take a look at my code so far
Populating the spinner:
public void addItemsOnSpinner() {
Spinner buttonSpinner = (Spinner) findViewById(R.id.buttonSpinner);
List<String> list = new ArrayList<String>();
list.add("Ultimos 5 lancamentos");
list.add("Ultimos 7 lancamentos");
list.add("Ultimos 10 lancamentos");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
buttonSpinner.setAdapter(dataAdapter);
}
Trying to make an if statement:
if(buttonSpinner.getSelectedItem().toString() == "Ultimos 10 lancamentos"){
textView.setVisibility(View.VISIBLE);
}
TextView code as requested:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Deposito"
android:visibility="invisible"
android:id="#+id/textView"
android:layout_row="2"
android:layout_column="0"
android:layout_gravity="center|left" />
And its code on the class:
TextView textView = (TextView)findViewById(R.id.textView);
Yes you can do it and it will work fine, but please use
buttonSpinner.getSelectedItem().toString().equals("Ultimos 10 lancamentos");
As Stefano has pointed out, your comparison should be using equals (which compares the String contents, vs == which compares the object references).
Otherwise your if statement should work, however its not clear where you are calling it from (and that might be the cause of the problem). If you want to make the comparison immediately after a spinner item is selected then you need to set an OnItemSelectedListener and make the comparison there.
Here is an example of how you might declare this listener inline:
buttonSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
String selectedItem = parent.getSelectedItem().toString();
if (selectedItem.equals("Ultimos 10 lancamentos"))
{
textView.setVisibility(View.VISIBLE);
}
}
public void onNothingSelected(AdapterView<?> parent)
{
}
});
I'm still very new to application development, so this is probably a very stupid question but I can't seem to find the right answer (or at least one that I can understand with my very limited knowledge of java).
I'm using a custom ArrayAdapter called ListRow. It works fine with a regular Activity, but not with the ListActivity that I need it to be in for my app to work.
Below is a sample of the code that I'm using. Any help would be greatly appreciated and you'd be helping a ton!
ListView mListview;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ListRow(this, THEME_NAMES, THEME_ICONS));
getListView().setTextFilterEnabled(true);
}
public class ListRow extends BaseAdapter {
private Context mContext;
private String[] mThemeNames = THEME_NAMES;
private int[] mThemeIcons = THEME_ICONS;
public ListRow(Context c, String[] t, int[] i) {
mContext = c;
mThemeNames = t;
mThemeIcons = i;
mListview=(ListView)findViewById(R.id.list);
}
#Override
public int getCount() {
return mThemeNames.length;
}
#Override
public Object getItem(int arg0) {
return null;
}
#Override
public long getItemId(int arg0) {
return 0;
}
#Override
public View getView(int position, View converView, ViewGroup parent) {
View List;
if(converView==null){
List=new View(mContext);
LayoutInflater mLayoutinflater=getLayoutInflater();
List=mLayoutinflater.inflate(R.layout.list_view, parent, false);
} else {
List = (View)converView;
}
ImageView imageView = (ImageView)List.findViewById(R.id.image);
TextView textView = (TextView)List.findViewById(R.id.text);
imageView.setImageResource(mThemeIcons[position]);
textView.setText(mThemeNames[position]);
return List;
}
}
And here's the layout I've defined for each list item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:id="#+id/image"
android:layout_alignParentLeft="true"
android:contentDescription="#string/preview" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/image" />
</RelativeLayout>
If you can, please use small words with me lol, java has turned out to be hard to understand for me, and also try to explain as much as you can. Thanks in advance!
FIGURED IT OUT!
So I just put you all through a bit of hell. The layout that contains my list items is called list_item, not list_view. However I have learned a lot here so THANK YOU ALL VERY MUCH! I wish there were a way I could help you guys out...
Moral of this question? CHECK YOUR LAYOUT NAMES!!
You need to set The Adapter in this way
setListAdapter(new ListRow(this, your_theme_names_array, your_theme_icon_array));
You dont need to use ArrayAdapter for this, that is just for Creating a Adapter for an array of String
EDITED
The Layout XML does not have the problem i think.
Check the List given below one by one
Check List
Check Whether R.layout.list_view point to the layout you given in the Question.
Try this for setting adapter setListAdapter(new ListRow(this, String[] { }, int[] { })); it will show you blank screen (If you get the Blank Screen that means either THEME_NAMES or THEME_ICONS is null or their values is null)
Remove the Line imageView.setImageResource(mThemeIcons[position]); and
textView.setText(mThemeNames[position]); this will also give u blank screen (If you get blank screen then R.layout.list_view does not contain R.id.image or R.id.text.
You have to add your mListView in your ArrayAdapter in setListAdapter.Only then the contents of your listview will be display in the pattern you have mentioned in customadapter. I cannot see where you have added elements in listview.