Android :: Get Data Index Of Visible Item
Jan 4, 2010
I have an Android ListView created with a SimpleAdapter that has more items in it than fit in the screen. After the list has been scrolled, I need to get the position in the data model of the first visible item in the list.Basically I want a function like: listView.getChildAt(0).getPositionInDataModel().Adapter has a few functions in it, like getItemId(position) that looked useful; however, the SimpleAdapter implementation just returns the passed in position, not a row id like I'd hoped.A brute force solution would be to get the View at index 0, and compare it to the view for each item in the adapter.However, there doesn't seem to be an easy way to get the view for a particular position from the adapter.
View 3 Replies
Oct 7, 2010
Other than using listeners, is there any way by which i can get index of an item in the list?
View 2 Replies
View Related
Jun 4, 2010
I need to get item's index(position) knowing its ID while using ExpandableListView. Is there any way to do this without making complete hash id->index and searching it?
View 1 Replies
View Related
Mar 26, 2010
I am creating a list .. the elements of the list are drawn from sqlite database .. I populate the list using ArrayList and ArrayAdapter ...upon clicking the items on the list I want to be able to fire an intent containing info about the item clicked ... info like the index number of the item .. using the method : onItemClick(AdapterView av, View v, int index, long arg)
I do get index of the item clicked . however it is of the list currently displayed . the problem comes when I do setFilterTextEnabled(true) , and on the app type in some text to to search some item ..and then click it ..rather than giving me the index of the item on the original list it gives me the index on filtered list..
following is the snippet of code:
myListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int index, long arg) {
Intent lyricsViewIntent = new Intent(iginga.this, LyricsPage.class);
lyricsViewIntent.putExtra("title", songList.get((int)arg).getTitle());
lyricsViewIntent.putExtra("id", songList.get((int)arg).getSongId());
startActivity(lyricsViewIntent);
}
});
myListView.setTextFilterEnabled(true);
Is there any way I can get the original index /position of the item instead of the one showing in filtered text ...when filtered.
View 1 Replies
View Related
Jan 11, 2010
How can I change the first visible item in a list view (I searched a method such as setFirstVisiblePosition) ?
View 2 Replies
View Related
Jun 6, 2010
I have a spinner, which mostly works. If a user selects one of the items in it, the 'onItemSelected' routine catches it just fine.
But if a user clicks the same spinner, but does not change from the already visible item that it's currently displaying, the 'onItemSelected' routine just ignores it, and the logs show:-
WARN/InputManagerService(577): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@437948b0
I there anyway to capture someone doing this? The idea is that my spinner contains a list of names, and when a user selects one from the spinner, it gets added to a listview.
I could just add another button to get the name from the spinner, but, screen-space is already lacking and I'd rather not add anymore content.
View 3 Replies
View Related
Jan 14, 2010
Does anyone know how to make a ListView object larger such that more than one Entry item is visible at the same moment ? Both parents are already set with "fill_parent" but the view continues to show one-and- a-half Entries.
View 5 Replies
View Related
Jun 6, 2010
I noticed that my data connection is always (3g is always visible). i know how to turn it off through settings, but when i try to use any apps that require internet connection, i would have to go through the settings and turn it on manually. is it possible to make this experience easy? i would like something that can easily and quickly turn the connection off and automatically turn it on when it needs to be on?
View 3 Replies
View Related
Sep 21, 2009
When i ran my old application in 1.6 i noticed that the progress bar was not showing up on the screen.When i analyzed it further i found the issue.The progress bar is getting activated but its not visible since my background color is also white.When i changed the background color i was able to see the progress bar.Is there no other way to make the progress bar visible other than changing the background color..Shouldn't the progress bar be visible under all background colors??
View 2 Replies
View Related
Mar 20, 2010
I recently upgraded my Android app to support multiple resolutions. Previously, my Android.manifest file had a line:
To support multiple density and resolution devices, I changed this to:
CODE:............
I then added a couple of new directories, like drawable-hdpi-v4 and drawable-long-hdpi-v4 that includes the high-res versions of the graphics. That's about it.
Ever since releasing this update, there have been a decent number of users complaining about various problems:
the app icon doesn't appear (I did not create a high res version of the icon)
the home screen widget no longer works, even if they delete and re-add it (this code did not change with the update). I've had a user send me their error log, which shows:
CODE:................
There is one questionable section in my existing widget code that may be relevant:
CODE:..........
And perhaps most troublesome: the sqlite database is no longer accessible/writeable for some users so their data is no longer available. I did add the WRITE_EXTERNAL_STORAGE permission to the manifest. This is only happening to certain users and it tends to be HTC Eris users. In that error log I see things such as:
CODE:.........
It's as if the update has caused a new process and it can't access the old process's data, or something.
View 1 Replies
View Related
Nov 21, 2009
Newbie question. I'm using a SimleCursorAdapter to populate a spinner from an SQLite table, as shown in the Android dev docs. Code...
I've set up a listener, but I can't figure out how to get the selected item text, it pulls up the SQLiteCursor, not the actual text in the spinner.Code...
Google turns up the question on several message boards, but no answers, so it appears to be a common newbie question. It may be painfully obvious to some.
View 3 Replies
View Related
Oct 7, 2010
I have a listView of contacts that I got from the Android ContactManager sample. This list is showing up fine, but I can't figure out how to get info from the selected item, like "name" and "phone number".
I can get the selected position, but the result of the mContactList.getItemAtPosition(position) is a ContentResolver$CursorWrapperInner and that doesn't really make any sense to me. I can't get heads or tails from that.
Anyone know how I can get the name/id/phone number from the selected item in the listView?
Here is my code.
code:................
View 1 Replies
View Related
Apr 9, 2010
I don't know exactly how to explain this problem, but I'll try. I have a ListView with several items. Each item has inside a TextView and two ImageView. I want the ImageView change when I click on them, and I want to open a context menu when I press for a long time into the ListView item.For the ImageView, everything works properly. For the whole item, I can show the context menu after a long press, but my problem is that the ImageView changes as well when I am pressing the TextView, for example.I hope you understand my problem. I think that all the children of a view are affected by an event in the parent, but I am not sure.
View 2 Replies
View Related
Nov 20, 2010
I jave a list of item (linearlayout inside a scrollview where i add buttons vertically to linearlayout dynamically from the java code)i need when i click on one button the item moves up (scroll up) , to make the item at the first of the screen
View 1 Replies
View Related
May 25, 2010
I need to get an item's position in spinner knowing it's ID. I've tried to do it with Spinner and SpinnerAdapter classes but there are no corresponding methods there.
View 2 Replies
View Related
Jul 27, 2010
How can I link like the Checkbox and larger TextView to external data? Should I use a SimpleCursorAdapter? Or create my own adapter? Should it extend ArrayAdapter or BaseAdapter? My list item UI:
View 1 Replies
View Related
Mar 21, 2010
could anyone point me to some examples on how to achieve Tableview with section and Index on Section. Similar to one it's in iPhone => http://www.iphonesdkarticles.com/2009/01/uitableview-indexed-table-view.html
View 3 Replies
View Related
Jul 26, 2010
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/llAddNote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="8dip"
android:background="#CCFFCC">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="24dip"
android:text="Add Notes"/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dip"
android:layout_marginRight="24dip"
android:id="@+id/tlNotes"
android:stretchColumns="0">
</TableLayout>
<Button
android:id="@+id/bAddNoteLine"
android:layout_marginLeft="24dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ADD">
</Button>
<LinearLayout
android:id="@+id/llIndex"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="21dip"
android:gravity="center">
<Button
android:id="@+id/bSaveSubjectiveNote"
android:layout_width="192dip"
android:layout_height="wrap_content"
android:text="Save"/>
<Button
android:id="@+id/bDiscardSubjectiveNote"
android:layout_width="192dip"
android:layout_height="wrap_content"
android:layout_marginLeft="48dip"
android:background="@drawable/button"
android:text="Discard"/></LinearLayout>
</LinearLayout>
How to retrieve the index of linearLayout which has "llIndex" as id.
View 1 Replies
View Related
Mar 26, 2010
I want to obtain the index of the selected item in a spinner.
I am aware of the method getSelectedItem() which returns the item selected (which might be a String). But i want the index of the selected item.
Something equivalent to the setSelection(index) to set the selected item.
Of course I can get the selected item and compare it against the array of items to obtain the index, but I hope there is a better way of doing this.
View 2 Replies
View Related
Jan 28, 2010
I added android:fastScrollEnabled="true" to the xml description of my listview class. I was (probably mistakenly) expecting this to magically transform the scrolling of my really huge listview so that the thumb button and the indexes display on the right side.
Is there more to hooking up the listview so that the framework knows what its alphabetizing? I have custom defined cells.
View 3 Replies
View Related
Aug 13, 2010
I have a binary file which contains keys and after every key there is an image associated with it. I want to jump off different keys but could not find any method which changes the index positioning in input stream. I have seen the mark() method but it does not jump on different places.
Does anybody have any idea how to do that?
View 1 Replies
View Related
Aug 23, 2010
Is it possible to have an index on the righthand side of a ListView? This is possible on the iPhone where running down the righthand side the alphabet is shown. Touching a letter on the alphabet brings one to the beginning of the items in the ListView that start with that letter.
Is there built-in code in Android for this functionality? Or is this something one would have to custom make?
View 2 Replies
View Related
Sep 21, 2009
I'm using OpenGL ES to display some objects exported from Blender. Blender provides a list of vertices, a list of the face indices and a list of the 2d texture co-ordinates. Within Blender, and I believe generally in OpenGL, the texture co-ordinates map to each vertex described in the index array.
I suppose I have two questions:
I'm given to understand(see the "Applying Textures" section) that in OpenGL ES the texture co-ordinates map to the vertex buffer only, not the index buffer. Is this the case or is there a way of binding the texture co-ords to the index buffer instead?
If the above is true, is there anything to be gained from using an index buffer at all? After all to properly map the textures one will need to write out the vertex buffer with all the redundancy that would have been saved with the index buffer. Is there still a performance increase to be gained or are index buffers redundant for textured data?
View 1 Replies
View Related
Aug 17, 2010
i have a map file which has several tile images in the form of binary data. now i have to jump my index to different location of the file and read that tile. but i could not find anything helpful for me i also checked mark() and skip() methods.but not helping me.is there any method or class which can do what exactly i want or any hint you want to give me.
View 1 Replies
View Related
Apr 28, 2010
I am making application in android just like the google finance. My first step is to show the market index summary, I have search the api list. But I could not get any api related to it. I do not want to use any java script. I need basically links this example if I put the symbol as GOOG it should display the information like this.
529.06 -2.58 (-0.49%) After Hours: 529.20 +0.14 (0.03%) Apr 27, 6:47PM EDT NASDAQ real-time data - Disclaimer
1. Range 527.23 - 538.33
2. 52 week 381.54 - 629.51
3. Open 528.94
4. Vol / Avg. 3.84M/3.64M
5. Mkt cap 168.46B
6. P/E 23.97
7. Div/yield
8. EPS 22.07
9. Shares 318.41M
10. Beta 1.11
and chart for this particular symbol.
View 3 Replies
View Related
May 19, 2010
I am using a ListView with an ArrayAdapter that holds objects. When I select an item, I am capturing the position and index of the selected item. If I scroll down prior to selection, the position and index represent the location of the item in the list. Selecting that items takes me to another activity. When I use the back button to return to the list, it seems that the ListView gets a new position and index for the visible items.
As a result, I can't figure out how to reference the selected item during the restart() of the ListView Activity. I have tried to capture position and index, but as I've said, they change upon returning to the Activity.
Is my understanding of the ListView "redraw" correct? Does it renumber my items based on what's visible? -When in the life cycle is getView() called? Is there a way to force an update to the ListView so that my captured index still points to the same object?
View 1 Replies
View Related
Jun 24, 2010
I have a problem with ArrayList. I'm using ArrayList like this:
CODE:.........................
Where Playlist is a class inherited from another ArrayList.
I do the following:
CODE:.........................
Later, when I use 'p' to get the index in the list:
CODE:.................
an index of '1' is returned, even though inspection of the list clearly shows that it's index '4'.
why this fails?
Same problem without indexOf(), using equals():
CODE:............
New edit:
This WORKS:
CODE:.............
Solution:
As suggested, I changed the Playlist class to not enherit from ArrayList, but rather keeping an instance privately. It turned out that I only had to implement 4 ArrayList methods.
This does the trick; Now indexOf() returns the correct object!
View 4 Replies
View Related
Feb 21, 2010
Is someArray[index] a faster way to get to a value than someObject.field?
E.g.: if(intArray[i] == 42) {//do stuff}
VS
if(someObject.x == 42) {//do stuff}
I will try to test it soon and post the results; just wondering if you all had any thoughts.
View 1 Replies
View Related
Oct 17, 2010
Trying to implement simple dictionary. I want to make it so while the user is typing in the EditText box the list to scroll automatically to the best match. I don't want it to filter the list. For example if the user types "s" in the EditText I want the first word that s/he sees under the EditText box to be the first word in the dictionary that starts with "s." But the user should still be able to slide up and down and to be able to see the entire list of words. It is basically like a go to functionality. I used ArrayList to store my list of words. The data is in res/raw/data.xml file. Here is my onCreate method
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
wordListView = (ListView)findViewById(R.id.wordList);
myEditText = (EditText)findViewById(R.id.myEditText);
words = new ArrayList<Word>();
arrAdap = new ArrayAdapter<Word>(this, android.R.layout.simple_list_item_1, words);
wordListView.setAdapter(arrAdap); try {
InputStream inSource = getResources().openRawResource(R.raw.data);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(inSource, null);
NodeList wordsList = doc.getElementsByTagName("eng-bg");
int length = wordsList.getLength();
for(int i = 0; i<length; i++) {
Element entry = (Element)wordsList.item(i);
Element eng = (Element)entry.getElementsByTagName("english").item(0);
Element bul = (Element)entry.getElementsByTagName("bulgarian").item(0);
Element id = (Element)entry.getElementsByTagName("ID").item(0);
String english = eng.getFirstChild().getNodeValue();
String bulgarian = bul.getFirstChild().getNodeValue();
int wordId = Integer.parseInt(id.getFirstChild().getNodeValue());
Word word = new Word(bulgarian, english, wordId);
addNewWord(word);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}wordListView.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
selectedWord = words.get(pos);
showDialog(TRANS_DIALOG);
myEditText.setText(selectedWord.getEnglish());
myEditText.addTextChangedListener(new TextWatcher(){
public void onTextChanged(CharSequence s, int start, int before, int count) {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
View 1 Replies
View Related
Feb 20, 2010
I have a TextView with an OnTouchListener. What I want is the character index the user is pointing to when I get the MotionEvent. Is there any way to get to the underlying font metrics of the TextView?
View 1 Replies
View Related