help for listview?

by Hitendrasinh Gohil » Thu, 19 May 2011 04:51:00 GMT

Sponsored Links
 ere is my class for listview. it has one edittext for
searching.whenever search button clicked data ll be loaded to
listview.but it is not happening.list is not populating with data.

can anyone suggest me what is the wrong with this code?

package com.musix.main;
import com.musix.model.JsonParser;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class TrackActivity extends SearchComponent
private ListView listview;
private OrderAdapter orderAdapter;
public void onCreate(Bundle instance)

ViewGroup viewgroup=(ViewGroup)findViewById(;

orderAdapter=new OrderAdapter(this);
private class OrderAdapter extends BaseAdapter
private LayoutInflater mInflater;

public OrderAdapter(Context context)
mInflater = LayoutInflater.from(context);

public View getView(int position, View convertView, ViewGroup
ViewHolder holder;

// Here if condition check view is null or not. If view
is null
then it will inflate
// album row and initialize it, otherwise it will get
tag and
assign it to holder.

if (convertView == null)
convertView =
mInflater.inflate(R.layout.trackrow, null);
holder = new ViewHolder();

holder.trackname = (TextView)
holder.trackalbum = (TextView)

holder = (ViewHolder) convertView.getTag();



return convertView;

public class ViewHolder
public TextView trackname, trackalbum;
public ImageView imgAlbumArt;

public int getCount(){return JsonParser.NEWSLIST.size();}
public Object getItem(int position){return position;}
public long getItemId(int position){return position;}

Re: help for listview?

by TreKing » Thu, 19 May 2011 05:25:41 GMT

 On Wed, May 18, 2011 at 3:50 PM, Hitendrasinh Gohil <

You import android.util.Log but don't have a single log statement.

TreKing <> ; - Chicago
transit tracking app for Android-powered devices


Sponsored Links

Re: help for listview?

by Justin Anderson » Thu, 19 May 2011 05:30:11 GMT

 Have you tried stepping through the code in the Eclipse debugger? What
happens when you do?

Justin Anderson
MagouyaWare Developer 


Re: help for listview?

by Hitendrasinh Gohil » Thu, 19 May 2011 12:03:19 GMT

 when activity loads frist time getview method is called but when i clicked
on search  data   orderAdapter.
orderAdapter.notifyDataSetInvalidated();,these methods called but not
reflcted in list.

then i have tried starting same activity and finish it on click event,in
that case oncreate method is called but getview is not called.

have u anyguess?

i simply want to load data on listview when search event is called?this
search is within three activities.

Hitendrasinh Gohil


Re: help for listview?

by gyanu maharjan » Thu, 19 May 2011 12:45:49 GMT

                       List<NameValuePair> nameValues=new
                       nameValues.add(new BasicNameValuePair("p","1"));
                       String data=new
+UrlConstants.SEARCH, nameValues);
                       new JsonParser().parseSearchTrackValue(data);

you want to set list view when search button is clicked,i think you should
set setContentView( belonging to listView and set suitable Adapter
for it.

On Thu, May 19, 2011 at 9:47 AM, Hitendrasinh Gohil <


Re: help for listview?

by Hitendrasinh Gohil » Thu, 19 May 2011 20:29:02 GMT


whether i am setting layout before click event or after it doesnt
affect.because we can notify list by calling its adapter

can can anyone please have a look at this ,and suggest where the problem is!


Re: help for listview?

by Francisco Dalla Rosa soares » Thu, 19 May 2011 20:53:27 GMT

 1. your ViewHolder class isn't static. if It's not it will always be null
for the next call. (this is not the reason for your problem though)

2. your getItem should be returning an object but it's returning just the

3. notifyDataSetInvalidated() means that the data inside the adapter is
no longer valid. This will cause ListView to stop populating (Romain Guy)

4.shouldn't you be calling notifyDatasetChanged() after that parse call?
2011/5/19 Hitendrasinh Gohil <>


Re: help for listview?

by Hitendrasinh Gohil » Thu, 19 May 2011 20:58:53 GMT


i have just called only notifyDatasetChanged(),but didnt work then i have
added   notifyDataSetInvalidated().

Hitendrasinh Gohil


Other Threads

1. GlobalSearch


  How to include my file search engine as a default search in
GlobalSearch Code.

Bhavani Prasad


2. custom layout for gridview


I'm attempting to create a class that extends GridView and has an
adapter to provide the information.

I believe I've grasped the adapter concept, however I can't work out
how to layout the children ....

After spending several hours attempting to make this work, I've got as
far as realising that you're supposed to set the size and position of
the children in the layoutChildren function.

However I have no idea how to actually do this.

I want to have it so that there is a 13x13 grid where the width and
height are set dynamically, so the smaller the available area, the
smaller the cells.

So the question becomes, can anyone help me with this please ?

Thank you very much.




3. WebView Load External HTML / Show Local Images

4. Intents that used to work stopped working.

5. External Database Connectivity

6. Archos WVGA/720p Tablet and Google Android Apps

7. Splintering of the Market