Android : How To Display A Special Message If A Filtered List View Contains No Results?
Mar 4, 2010Is there any way to show a message such as "No results" when i filter a list?
View 1 RepliesIs there any way to show a message such as "No results" when i filter a list?
View 1 RepliesI have a ListView with a custom Adapter that extends ArrayAdapter. It's ArrayAdapter of Type Artist. (There are about 1200 artists in my list). Artist is a very small class that has a name and an id. The Artist Class has toString() overridden to return just the name. I have an EditText. The EditText has an TextChangeListener where I call .getFilter().filter(chars, callback) on my adapter. In the Filter.Filterlistener().onComplete() callback i print the count and it looks really good. As i type the count decreases. So it seams everything works as advertised, but the List stays the same. I tried to call artistAdapter.notifyDataSetChanged() to force the list to redraw, but nothing happens. [see 2.)]. I am tinkering around for days now! I am desperate. Hopefully someone can have a look on my code and tell me what I am doing wrong! How can I force the list to be redrawn?
Here is what I have done:
1.) Defined a ListView and an EditText like this:
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_search_text"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_below="@id/header">
</EditText>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_search"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
2.) Setup my ListView in the Activities onCreate():
private ListView listView = null;
private ArtistAdapter artistAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_artists);
artistAdapter = new ArtistAdapter(this, R.layout.row, list); // 'list' is an ArrayList<Artist>
listView = (ListView) findViewById(R.id.list_search);
listView.setAdapter(artistAdapter);
listView.setFastScrollEnabled(true);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int position, long id) {
// do something } });
EditText txtSearch = (EditText) findViewById(R.id.list_search_text); txtSearch.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable arg0) { }
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { }
public void onTextChanged(CharSequence chars, int start, int before, int count) {
artistAdapter.getFilter().filter(chars, new Filter.FilterListener() {
public void onFilterComplete(int count) {
Log.d(Config.LOG_TAG, "filter complete! count: " + count);
artistAdapter.notifyDataSetChanged();
}});
}});
}
3.) This is my ArtistAdapter in short. I added an remove() and add() method:
public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexer {
private List<Artist> items;
/* other stuff like overridden getView, getPositionForSection,
getSectionForPosition and so on */
@Override
public void remove(Artist object) {
super.remove(object);
items.remove(object);
}
@Override
public void add(Artist object) {
super.add(object);
items.add(object);
} }
4.) My artist has also the toString() overridden:
public class Artist implements Comparable<Artist> {
public String uid;
public String name;
public Artist(String id, String name) {
this.uid = id;
this.name = name; }
public int compareTo(Artist another) {
return this.name.compareToIgnoreCase(another.name);
}
@Override
public String toString() {
return this.name;
} }
I am a new to Android stuff. I am creating an application that contains a list view that will get dynamically populated. My requirement is when the list is empty, I would like to show a message. I don't want to create additional views just for displaying this message. Is there any nice way to do this? Any suggestions?
View 3 Replies View RelatedI am trying to display a filtered version of the camera preview.
The code runs without errors but the device is showing the preview instead of the generated bitmap.
This is the code for my (very small) Activity: http://code.google.com/p/ruellia/source/browse/ruellia/src/br/com/ximp/ruellia/RuelliaActivity.java
I suspect the view layering and the surface holder type, but so far no luck... anyone?
I have a list view having several items and it is multichoice list. I want to display the checked item of list view. how i can do this.can anyone help me?
View 1 Replies View Relatedcan any one tell how to display the List with an Image in the left side of the view.
View 2 Replies View RelatedI am calling one webservice.Result of webservice I am storing in an Array list. Result of webservice I want to display as list view. For ListView I am using SimpleAdapter. and SimpleAdapter is something like this:- SimpleAdapter adapter = new SimpleAdapter(this,hashmap, layout, from, to);
I am not able to put array list into hashmap. Is there anyway to do this?
I never do graphics type programming. I'm designing a screen that will need to look good on all phones, and all resolutions. It's for displaying in a list view, and there will be a small graphic for the summary view, and a larger graphic for the detail view. Normally I use a 32x32 (res 72x72ppi).png for the summary view which looks good on my G1. The second image is for the detail view and it basically should fill the entire width of the screen (roughly, it's ok if it doesn't use the entire width as long as none of it is chopped off). The size I use for my G1 is 468x60.
So, the question for the guys that really know this stuff is: What sizes do I need to make these images to support all screens and densities with the fewest number of images? I know that the answer is a little subjective, but I remember seeing a post with a link to a page that recommended 3 different images for the different screens (and it seemed to make sense when I read it), and I think but don't remember for sure that then you would need 6 layouts to support those with both landscape and portrait orientations.
I have parsed the xml file. now aim is to display contents using list view as dynamically..
How it is possible?
I have two list view which is display data from the web service.
List 1 -- with different background
List 2 -- with different background
I have two ArrayAdapter<String> to handle the values. I have issue in the display. my xml file is structured as
<Linear Layout>
<ListView> </ListView>
<ListView> </ListView>
<Linear Layout>
its displays the two list items by dividing the screen into two equal parts and scrolls within the list individually.
I wanted the List 1 to be displayed fully and then followed by List 2 and also it should screen should be scroll not with in the list but full screen so that List 2 could be seen below.
i tired many ways but still the results are not fine.
I am on Android 2.1 and I have one multi column Custom listview Using BaseAdapter with an editable edittext at the end of the listview. If the data in the listview do not contain the data of user choice then user should be able to enter data. If the data is already there in the list user will be able to select the data using custom selector. If a selection is made in the list view and user wanted to enter data in the text field at the bottom after selection then the marker in the list view should be unselected. I tried to use onclick() method on edit text using click listener. First time when it is clicked, edit text is getting focus and onclick() method is not fired. And when it is clicked second time, onclick() method is fired and notifyDataSetChanged() method is called. I tried to call the notifyDataSetChanged() method from the Focus Listener, list view selection is gone in my first attempt and edit text is not receiving any data input from the keyboard (frozen).
View 1 Replies View RelatedI need an advice. What is the best way to implement in android a list of such UI elements (see the ref)A list contains a lot of such elements (about 30-40). I'm using now relative layout and 4 text fields and I think it isn't a good way.I think it's too heavy (full list will contain: 30 relative layouts and 30*5 = 150 text fields).
View 1 Replies View RelatedSpecifically music notes.
its not a horrible ordeal, just a very minor annoyance, HOWEVER
im curious as to whether or not theres some type of character set or language package i can apply that will show these types of characters.
example:
INCREDIBLE BROWSER
DESKTOP BROWSER
any ideas? p.s calling the phone a "DInc" is the stupidest thing on the planet.
Is it possible to develop an Android app that would answer an incoming call and play a recorded message to the calling party without the phone ringing? For example, if a specific caller called during certain hours play a message asking them to call a different number during those hours.
In a similar vein, is it possible to intercept a call and if it is in a certain list of phone numbers divert it directly to voice mail without the phone ringing?
Thanks for any insights into this
I'll try and explain this as best as possible...
If I search for a generic term at top it may say 5 results found, but in the search results it says to re word your search. Why won't it just tell me the 5 it found?
This is on a Sprint hero with 1.5 cupcake obviously.
I had been showing off the droids capabilities to a co-worker when he asked "how far away is the nearest place to get a haircut from the hotel". At this time we were still at the airport, so I couldn't just say "map of nearest haircut". So I got the map to display the embassy suites, but then couldn't get it to ALSO display places to get a haircut. It was one or the other. I worked on it for about an hour but couldn't figure this one out. Is there a way to display multiple results?
View 9 Replies View RelatedI want to display search result on the screen, I have implemented in such a way that. From the search form user fill the 'search field' and 'search location' I set values into bean and that bean is static so that I can access it from every where. Then I start search result screen intent using:
Intent mainIntent = new Intent(SearchVenueResults.this, SearchResults.class);
startActivity(mainIntent);
On the 'SearchResults' activity 'oncreate' method I load data on the behalf of static bean which values filled from search form and then display data.
@Override
public void onCreate(Bundle savedInstanceState) { loadDataAndSetupUI();
super.onCreate(savedInstanceState);
}
My question is is it the correct approach to use it or in Android there is another preferable approach?
I'd like to show another List View 'B' after clicking a item of List View 'A'. I use onListItemClick event in Android 1.6 project.
View 6 Replies View RelatedIs it possible to have a horizontal list view with an vertical list view? I would like to horizontal list scroll within a vertical list scroll.
View 13 Replies View RelatedI am trying to set up a ViewFlipper that changes a SlidingDrawers content each time a button is pressed. So far every view I set up worked fine, but now I am trying to create a ListView (including single_choice_mode) within a child view of the ViewFlipper, but my attempt only let to a NullPointerException. As I only discovered ViewFlipper today, I am not yet familiar with it and may not have understood it completely. if someone could give me a hand and help me find out what I have done wrong, that would be great. Here is what I have done:
The code for the onClick event of the ImageButtons:
public void onClick(View v){
if (v == btnExposure){
mFlipper.setDisplayedChild(0); }
else if (v == btnProperties){
mFlipper.setDisplayedChild(1);}
else if (v == btnSpecialEffects){
mFlipper.setDisplayedChild(2);.............
I am facing one problem in message view. Bacically what I need to do is in message view I want to mark any telephone number or web address in different color. Can anyone please tell me where exactly the text is been written in Message View? On clicking this items it should launch appropriate event. If anyone touches a telephone number it should launch the dialer or if it is a valid email address then it should launch the Compose message event and so on.
Another question is whether to display message is Android uses the WebView?
Is it possible to disable title bar display dynamically after setting the content view by setting the NoTitlebar theme?
All the posts I have read told that any title bar changes we can make only before setContentView() call.
How do I ensure that I get the 'resize' behavior when the IME is shown/hidden?
I've included the following in my manifest:
android:windowSoftInputMode="adjustResize"
What else am I supposed to add? I've read that the container that the View is placed in should 'support resize' but what layouts support this?
How i can display custom error message before foreclose or Application not responding message will happen for an application.
Or
Can i display Custom message like "Please wait....." instead of Application not responding message.
I am using a locally made make of phone called a Firefly. My last phone was a samsung, which was way too small and too slow.
When I first added my google account to my andoid phone, I thought nothing of it syncing the contacts. I did not realize that google had kindly created a contact for every single person I had ever emailed in my entire life. For most people, I am sure that this is quite an accurate list, but I manage a business, so I get lots of emails from people and systems that I never need on my phone.
When I first noticed this, I disabled syncing of contacts and manually removed all the contacts from my phonebook. This left me with a nice neat list of contacts. Great. But... When I go to send a text message and add a recipient, I am displayed with a gigantic list of thousands of contacts, most of whom are email addresses and at least 98% of whom are people I would never ever want to send a text message to.
I have searched everywhere, but can not find any way to access this contact list within my phone so I can clean it. The only solution I have been able to find is to first delete all contacts from google, then enable sync, then disable sync after it completes. This is really not ideal as I need these contacts in my google account, but not on my phone.
we are wroking on the displaying of mails from an email . we got the list of emails stored . we need to show a small text screen which consists of the some content of the body when the email in the list gets focus .
View 4 Replies View RelatedI'm trying to create a multiple selection list where the selection is represented graphically rather than with checkboxes.My list has checkboxes, but I want them to serve a different purpose. I'm using a cursor to hold my data and created a custom view binder for the SimpleCursorAdapter. I did this for the checkboxes and general flexibility.So far I haven't even been able to show one line as being selected. I've enabled multiple selection on the list and denied the children of the list item focusability. I've tried manually changing background color with the position fed in through the list item click listener. But the wrong items get changed and they don't even change to the right color. I've enabled touch focusability with no improvement either.Ideally, I'd like the trackball highlight focus bar to appear in multiple places. But I don't think this is possible unless you use the drawable directly. But I don't know how to find or apply it. My next idea was to have a slim view bar that changes color. But I had the same problem with the wrong item being selected so I never finished trying to guess the index position to see if this would work. My most recent idea is to completely swap out the view for another one if it's selected. But I have no idea how to do this either. I'm thinking of using an array list to store the _id s of the items that need a different view to get around the wierd selection problem. I'm also thinking of passing in the ID field as my from and the selection view as the to for my adapter. Then I'd intercept it with my binder and change the view accordingly. But once again, I'm not sure how to do this successfuly.
View 7 Replies View RelatedI am trying to display the text from json in a list view.But my problem is that i cant figure out how to display them in list view. I also want to get only some of the text from url(for example, alerttext and date). Can anyone help me in declaring the list adapter and list view in order to display the data in the way i want.
View 1 Replies View RelatedBy Default in the Listview,focus will come on the list item.Instead of that, can I get only the border to the list item?I can achieve this by using a transparent image as a list selector.Is there any other simplest way to achieve this requirement?
View 1 Replies View RelatedI've tried to add a TextView before a ListView in a LinearLayout. The result is that the ListView wont show at all. The same thing happens if I put the TextView after the ListView, but then I will only see the ListView. Is there a way to get a text view above the ListView without to much of a hassle?
View 10 Replies View Related