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. Sprite Type Images Guy

Hey Guys,

I was wondering if there was any sort of sprite support built into
Android? Currently, I've got TONS of tiny icon-ish files (40x100,
90x90) and it's taking up a considerable amount of space. The first
set is around 272KB total and the second is 432KB. When I sprite and
optimize the images, it comes out to 88KB and 152KB, a savings of
around 60%. Also, that 450kb just inflates the size of my apk
dramatically.

Is there any way to do Spriting? I use the icon currently in Images in
both Grid and ListViews.

Thanks!

Evan
--~--~---------~--~----~------------~-------~--~----~

2. When paid Apps will be supported in Canada?

I asked the same question to Rogers (local service provider) but they
told me to contact Google.

Thanks,

Alex

--~--~---------~--~----~------------~-------~--~----~

3. Untrusted ssl root CA

4. problem with startActivityForResult function

5. Problem receiving orientation changes

6. Send Email without using the android builtin app

7. Problem in add icon to listview