Need help on List Adapter

by Ramesh Sangili » Sun, 30 May 2010 10:32:01 GMT


Sponsored Links
 Guys,

  I am extending BaseAdapter and trying to populate the List Screen on my
Activity Screen. NotifyDataSetChanged is not working as expected. Please
find the below snippet of code. Please do let me know your thoughts.







 public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
 initialize();
context = this;
config = Config.getInstance();
searchText =  new EditText(this);
 handler = new Handler() {
 @Override
public void handleMessage(Message msg) {
msgQueueAdapter.notifyDataSetChanged();
context.msgQueueAdapter.notifyDataSetChanged();
msgQueueAdapter.notifyDataSetInvalidated();
}
};
 searchText.addTextChangedListener( new TextWatcher() {
 @Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
// TODO Auto-generated method stub
Log.d("on text", "String: " + s);
loadData(s.toString());
msgQueueAdapter = new ListAdapter(context, msgQueueList);
Message msg = handler.obtainMessage();
handler.sendMessage(msg);
searchText.bringToFront();
 runOnUiThread(new Runnable()  {
 @Override
public void run() {
msgQueueAdapter.notifyDataSetChanged();
searchText.setCursorVisible(true);
searchText.setClickable(true);
}
});
}
 @Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
 }
 @Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
 }
});
 msgQueueAdapter = new ListAdapter(this, msgQueueList);
Log.d("list", "List Display - 1" + msgQueueAdapter);
 msgQueueListView = this.getListView();
msgQueueListView.addHeaderView(searchText);
 setListAdapter(msgQueueAdapter);
msgQueueAdapter.notifyDataSetChanged();
this.msgQueueAdapter.notifyDataSetInvalidated();
}

--



Need help on List Adapter

by Ramesh Sangili » Sat, 05 Jun 2010 10:58:46 GMT


 Any help is greatly appreciated!!!

Please guys share your thougths





--


Sponsored Links


Need help on List Adapter

by igo where » Sat, 05 Jun 2010 12:43:11 GMT


  think you should  not need to montior the change, one thing you need do is
to change the baseAdapter ,i do like this

public SimpleAdapter initAdapter(
ArrayList<HashMap<String, String>> listDataSource) {
SimpleAdapter mSchedule = new SimpleAdapter(this,
listDataSource,
R.layout.left_ticket_list_item,// ListItemML
new String[] { String.valueOf(R.string.ret_id),
String.valueOf(R.id.train_no),
String.valueOf(R.id.start_time),
String.valueOf(R.id.arrive_time),
String.valueOf(R.id.esep_time),
String.valueOf(R.id.left_hard_seat),
String.valueOf(R.id.left_hard_berth),
String.valueOf(R.id.left_soft_berth),
String.valueOf(R.id.left_LevOne_Seat),
String.valueOf(R.id.left_LevSec_Seat) }, new int[] {
R.id.query_ret_id, R.id.train_no, R.id.start_time,
R.id.arrive_time, R.id.esep_time,
R.id.left_hard_seat,
R.id.left_hard_berth, R.id.left_soft_berth,
R.id.left_LevOne_Seat, R.id.left_LevSec_Seat });
return mSchedule;
}
public void showQueryLeftTicketRet(
ArrayList<LeftTicketInfo> al_retleftTicketInfo) {
HashMap<String, String> queryRetListMap = new HashMap<String,
String>();
queryRetList.clear();
if (al_retleftTicketInfo.size() == 0) {
this.showQueryRet.setVisibility(0);
} else {
this.showQueryRet.setVisibility(2);
for (int i = 0; i < al_retleftTicketInfo.size(); i++) {
queryRetListMap = new HashMap<String, String>();
queryRetListMap.put(String.valueOf(R.string.ret_id),
al_retleftTicketInfo.get(i).id);
queryRetListMap.put(String.valueOf(R.id.train_no),
al_retleftTicketInfo.get(i).trainNo);
queryRetListMap.put(String.valueOf(R.id.start_time),
al_retleftTicketInfo.get(i).startTime);
queryRetListMap.put(String.valueOf(R.id.arrive_time),
al_retleftTicketInfo.get(i).arriveTime);
queryRetListMap.put(String.valueOf(R.id.esep_time),
al_retleftTicketInfo.get(i).esepTime);
queryRetListMap.put(String.valueOf(R.id.left_hard_seat),
al_retleftTicketInfo.get(i).leftHardSeat);
queryRetListMap.put(String.valueOf(R.id.left_hard_berth),
al_retleftTicketInfo.get(i).leftHardBerth);
queryRetListMap.put(String.valueOf(R.id.left_soft_berth),
al_retleftTicketInfo.get(i).leftSoftBerth);
queryRetListMap.put(String.valueOf(R.id.left_LevOne_Seat),
al_retleftTicketInfo.get(i).leftLevOneSeat);
queryRetListMap.put(String.valueOf(R.id.left_LevSec_Seat),
al_retleftTicketInfo.get(i).leftLevSecSeat);
queryRetList.add(queryRetListMap);
//Log.v("INFO", al_retleftTicketInfo.get(i).id);
}
}

this.queryLeftTicketRetListView.setAdapter(initAdapter(queryR



Need help on List Adapter

by Indicator Veritatis » Sat, 05 Jun 2010 13:09:44 GMT


 My main thought on glancing at this is: you are more likely to get the
help you want if you tell us more. What, for example, do you expect
NotifyDataSetChanged() to do? What data has changed, and what View are
you expecting needs to be updated to reflect the change?

Maybe you will luck out and find a reader more willing to do "code
diving", but I am not in the mood to reverse-engineer your code to
figure out the answers to these questions tonight myself.





--



Need help on List Adapter

by Tommy » Tue, 08 Jun 2010 02:57:14 GMT


 re you getting any errors? what do you mean by NofifyDataSetChanged is not
working as expected?



From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Ramesh Sangili
Sent: Friday, June 04, 2010 10:58 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Need help on List Adapter



Any help is greatly appreciated!!!



Please guys share your thougths

On Sun, May 30, 2010 at 8:01 AM, Ramesh Sangili <ramesh.sang...@gmail.com>
wrote:

Guys,



I am extending BaseAdapter and trying to populate the List Screen on my
Activity Screen. NotifyDataSetChanged is not working as expected. Please
find the below snippet of code. Please do let me know your thoughts.

















public void onCreate(Bundle savedInstanceState) {



super.onCreate(savedInstanceState);



initialize();

context = this;

config = Config.getInstance();

searchText = new EditText(this);



handler = new Handler() {



@Override

public void handleMessage(Message msg) {


msgQueueAdapter.notifyDataSetChanged();


context.msgQueueAdapter.notifyDataSetChanged();


msgQueueAdapter.notifyDataSetInvalidated();

}

};



searchText.addTextChangedListener( new TextWatcher()
{



@Override

public void onTextChanged(CharSequence
s, int start, int before, int count) {

// TODO Auto-generated
method stub

Log.d("on text", "String: "
+ s);

loadData(s.toString());

msgQueueAdapter = new
ListAdapter(context, msgQueueList);

Message msg =
handler.obtainMessage();

handler.sendMessage(msg);

searchText.bringToFront();



runOnUiThread(new Runnable()
{



@Override

public void
run() {


msgQueueAdapter.notifyDataSetChanged();


searchText.setCursorVisible(true);


searchText.setClickable(true);

}

});

}



@Override

public void
beforeTextChanged(CharSequence s, int start, int count,




Need help on List Adapter

by Ramesh Sangili » Thu, 10 Jun 2010 01:19:29 GMT


  would like to display the list dynamically filtered by the text input
entered by the user on the textbox. the Problem that I am facing
NotifyDataSetChanged() is refreshing the list based on the text input

On Tue, Jun 8, 2010 at 12:26 AM, Tommy <droi...@gmail.com> wrote:

>



Other Threads

1. How to prevent AlarmManager erased schedulations by TaskManager

I managed to find a workaround for this problem very easy.

"Kills me before he does TaskManager".

The schedule remains in AlarmManager if the application kills itself when 
paused or stopped and the user closed the application.

System.exit (0) in onPause () and OnStop ()

If the application is already killed when TaskManager is running, scheduling in 
AlarmManager is not lost.

Is lost if the application is paused or stopped.

I hope it will be useful.
In my case it is.

Thank you.

--- Mer 16/6/10, Mark Murphy <mmur...@commonsware.com> ha scritto:

Da: Mark Murphy <mmur...@commonsware.com>
Oggetto: Re: [android-discuss] Re: How to prevent AlarmManager erased  
schedulations by TaskManager
A: android-discuss@googlegroups.com
Data: Mercoled 16 giugno 2010, 00:05




They get de-fanged in Android 2.2, though, in that they will no longer
be able to get rid of AlarmManager alarms, for example.


This paragraph made no sense to me. What is "taken out of context by
the container", for example?

-- 
Mark Murphy
CommonsWare
mmur...@commonsware.com
http://commonsware.com

-- 

2. Making a jar of an android project for use by third party apps?



I set up some tech for this as part of the Android Parcel Project:

http://andparcel.com/

In particular, these instructions for creating a parcel may be of interest:

http://andparcel.com/pdfs/parcel-dev.pdf

Also, the current version of _The Busy Coder's Guide to Advanced
Android Development_ has a chapter on creating reusable components
like these. Since you're a subscriber, you should have access to this
version of the book.

-- 
Mark Murphy
CommonsWare
mmur...@commonsware.com
http://commonsware.com

-- 

3. Making a jar of an android project for use by third party apps?

4. How To Setup A Blacklist For Incoming Calls/Texts

5. OnSharedPreferenceChangeListener never receives callback

6. how to programatically pause an application?

7. Screen touches during game