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)
{
super.onCreate(instance);

ViewGroup viewgroup=(ViewGroup)findViewById(R.id.FrameLayout01);

ViewGroup.inflate(getApplicationContext(),R.layout.track,viewgroup);
listview=(ListView)findViewById(R.id.tracklist);
orderAdapter=new OrderAdapter(this);
listview.setAdapter(orderAdapter);
}
private class OrderAdapter extends BaseAdapter
{
private LayoutInflater mInflater;

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

public View getView(int position, View convertView, ViewGroup
parent)
{
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)
convertView.findViewById(R.id.trackname);
holder.trackalbum = (TextView)
convertView.findViewById(R.id.albumartistname);

convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}


holder.trackname.setText(JsonParser.TRACKDETAILS.get(position).getTracktitle());

holder.trackalbum.setText(JsonParser.TRACKDETAILS.get(position).getArtistname());

convertView.setOnClickListener(new
OnItemClickListener(position));
return convertView;
}

public class ViewHolder
{
public TextView trackname, trackalbum;
@SuppressWarnings("unused")
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 < http://sites.google.com/site/rezmobileapps/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?

Thanks,
Justin Anderson
MagouyaWare Developer
 http://sites.google.com/site/magouyaware 







-- 



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.
notifyDataSetChanged();
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.



-- 
Regards,
Hitendrasinh Gohil

-- 



Re: help for listview?

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


 case R.id.btnsearch:
                       List<NameValuePair> nameValues=new
ArrayList<NameValuePair>();
                       nameValues.add(new
BasicNameValuePair("t",
edittext.getText().toString()));
                       nameValues.add(new BasicNameValuePair("p","1"));
                       String data=new
HttpRetriever().getSearchdata(UrlConstants.BASEURL
+UrlConstants.SEARCH, nameValues);
                       new JsonParser().parseSearchTrackValue(data);
                       break;

you want to set list view when search button is clicked,i think you should
set setContentView(R.id.list) 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


 hi,

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

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
position

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 <hitendra.virtuei...@gmail.com>


-- 



Re: help for listview?

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


 hi,

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


-- 
Regards,
Hitendrasinh Gohil

-- 



Other Threads

1. Do someone know which application controls USB connected notification

It isn't an application, it is part of the core system.




> 

2. Disconnect Incoming Call in Android

hello frnds....

i m trying to disconnect incoming call from my application.

i have done with Automatic Answer with this code

Intent new_intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
new_intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(
KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));

getApplicationContext().sendOrderedBroadcast(new_intent, null);


but now i want to disconnect call in some situation. how can achieve this in
android.


Plz help me...

Thanks and Regrads
bhavesh



-- 
B!-!/-\\/!=$!-!

-- 

3. Two buttons side by side to fill width of screen?

4. how do i get xmlresourceparser?

5. Error:cannot launch the init of ramdisk.img

6. How to repeatedly draw on a canvas

7. Picking two pictures at once