0

I'm trying to change one TextView in any view in my ListView,

And I already got one Adapter set so I can't use adapters for this.

I tried to do it in a "for" statement, using

mListView.getChildAt(i)

but it didn't worked.

when I tried to do it inside the OnItemClick method, using arg1 instead of

mListView.getChildAt(i), it worked for the item I clicked.

But i need it to happen without clicking on an item,

So my question is: What is the value of Arg1 and Arg2?

I know what they represent, but I want to know what value do they get when I click on an item.

Thanks.

user3184899
  • 3,019
  • 6
  • 30
  • 38
  • does it mean you don't have adapter for your list view? if you have, you implement getItem inside your adapter. like : `@Override public Object getItem(int position) { return itemList.get(position); }` – Jimmy Jun 22 '14 at 19:40
  • `getItem()` returns String, not View. – user3184899 Jun 22 '14 at 19:53
  • nope.It returns what you have in your list. i.e. itemList in above example code. – Jimmy Jun 22 '14 at 19:55
  • my adapter is ArrayAdapter set with values inside the brackets. it returns String when I ask for getItem. I need it to get view, how do I do it? – user3184899 Jun 22 '14 at 19:57
  • I think you should add all relevant codes in your question so that SO user understand exactly what you mean. – Jimmy Jun 22 '14 at 19:58
  • I would suggest you to create custom adapter instead of using ArrayAdapter which extends base adapter. and override methods : getItem(), getView(),getItemId(), and getCount(). It will make your life easy for sure. – Jimmy Jun 22 '14 at 20:00
  • I'm using ArrayAdapter to match a list to TextView in any view, which is basically what I'm trying to do without adapter. – user3184899 Jun 22 '14 at 20:07
  • So, lets take it the other way. Is there A way that I could set more than one adapter to a single listview? – user3184899 Jun 22 '14 at 20:08
  • I am not aware of that scenario. But you can customize your one adapter for almost all your needs for one type of list view contents. – Jimmy Jun 22 '14 at 20:14
  • "I'm using ArrayAdapter to match a list to TextView in any view, which is basically what I'm trying to do without adapter." Is there A way to match multiple lists to multiple TextViews in one ArrayAdapter? – user3184899 Jun 22 '14 at 20:27

2 Answers2

1

you can fake a click through view.performClick() method if that is what you need

ozbey
  • 160
  • 1
  • 7
  • `mListView.getChildAt(6).performClick();` for example, gives NullPointerException. – user3184899 Jun 22 '14 at 19:49
  • that is because android will recycle through your list view please refer to this answer http://stackoverflow.com/questions/11945563/how-listviews-recycling-mechanism-works – ozbey Jun 22 '14 at 19:59
0

From Android documentation :

public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id)

Callback method to be invoked when an item in this AdapterView has been clicked.

Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.

Parameters :

parent The AdapterView where the click happened.

view The view within the AdapterView that was clicked (this will be a view provided by the adapter)

position The position of the view in the adapter.

id The row id of the item that was clicked.

CodeWarrior
  • 5,026
  • 6
  • 30
  • 46
  • I need Arg1 value. how can I get Arg1 value (View) using getItemAtPosition? I couldn't find a way. I get it that this method gets the View and Position, but how? what is the value they get set to? – user3184899 Jun 22 '14 at 19:36
  • @user3184899 It's a callback event. It is called whenever the view is touched. You just can't simple get the value by using `getItemAtPosition()` – CodeWarrior Jun 22 '14 at 19:43
  • let me ask it different. how can I get an Array of all of my ListView views? – user3184899 Jun 22 '14 at 19:47