setOnItemClickListener on Listview that extend activity - java

Update : I found the solution by
removing
v.setFocusable(true);
v.setClickable(true); in the code
and only add
v.setEnabled(true);
and in my xml (ListView) add
android:drawSelectorOnTop="true"
android:focusable="true"
When I click it nothing happens , even the list view doesn't focus.
I have tried to add all this:
v.setClickable(true);
v.setEnabled(true);
v.setFocusable(true);
Only this will work is i add the following code:
But this doesn't determine what item is being clicked
How to handle ListView click in Android
and the result still the same.
Here's is the code :
public class AppsInspectorActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//[...]
ListView app_listView = (ListView)findViewById(R.id.listview);
// I try setOnItemClickListene here - 1
app_listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(), "I Clicked on Row " + position + ".", Toast.LENGTH_SHORT).show();
}
});
}
Adapter
public class AppAdapter extends BaseAdapter {
Context context;
ArrayList<AppInfo> dataList=new ArrayList<AppInfo>();
public AppAdapter(Context context,ArrayList<AppInfo> inputDataList)
{
this.context = context;
dataList.clear();
for(int i=0;i<inputDataList.size();i++)
{
dataList.add(inputDataList.get(i));
}
}
public int getCount() {
// TODO Auto-generated method stub
return dataList.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return dataList.get(position);
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View v=convertView;
final AppInfo appUnit = dataList.get(position);
ListView app_listView = (ListView)findViewById(R.id.listview);
/** Remove this , i just try to add to see setOnItemClickListener will work at here or not **/
app_listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(), "I Clicked on Row " + position + ".", Toast.LENGTH_SHORT).show();
}
});
if(v==null)
{
LayoutInflater vi=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v=vi.inflate(R.layout.app_row, null);
v.setClickable(true);
v.setEnabled(true);
v.setFocusable(true);
}
TextView appName=(TextView)v.findViewById(R.id.appName);
ImageView appIcon=(ImageView)v.findViewById(R.id.AppIcon);
if(appName!=null)
appName.setText(appUnit.appName);
if(appIcon!=null)
appIcon.setImageDrawable(appUnit.appIcon);
return v;
}
}
}
}

Can you please post the main.xml layout. Seems to me that you have another view on top of the listview that is consuming the touch events.

I found the solution by removing
v.setFocusable(true); v.setClickable(true); in the code
and only add
v.setEnabled(true);
and in my xml (ListView) add
android:drawSelectorOnTop="true" android:focusable="true"

Hi remove the setOnItemClickListener in the getView of the Adapter.Refer this listView

use AppsInspectorActivity.this instead of getApplicationContext()
public class AppsInspectorActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//[...]
ListView app_listView = (ListView)findViewById(R.id.listview);
// I try setOnItemClickListene here - 1
app_listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(AppsInspectorActivity.this, "I Clicked on Row " + position + ".", Toast.LENGTH_SHORT).show();
}
});
}
and remove the setOnItemClickListener from the getView() method in your adapter

Change your getView() to below one and tell if it works
public View getView(int position, View convertView, ViewGroup parent) {
View v=convertView;
final AppInfo appUnit = dataList.get(position);
if(v==null)
{
LayoutInflater vi=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v=vi.inflate(R.layout.app_row, null);
v.setClickable(true);
v.setEnabled(true);
v.setFocusable(true);
}
TextView appName=(TextView)v.findViewById(R.id.appName);
ImageView appIcon=(ImageView)v.findViewById(R.id.AppIcon);
if(appName!=null)
appName.setText(appUnit.appName);
if(appIcon!=null)
appIcon.setImageDrawable(appUnit.appIcon);
return v;
}

You have to set adapter to listview before setting its onItemClick.Here you just get the listview but with no items.so when you click on listview,its onItemClick is never called.

Related

Start chronometer on each row of Listview in android

I have list items on one list layout among items i have there is a chronometer that i need to start on each row ,other items come from database, but when activity launches Chronometer stays on 00:00. Please help me , i did many research some tell me that in can use adapter but i am not familiar with it, i don't know if there is not another way to do it without using adapter .
MainActivity .java:
private ArrayList<HashMap<String, String>> userList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myList = (ListView)findViewById(R.id.listView);
inflatedView =
getLayoutInflater().inflate(R.layout.payement_timing_list_adapter_view, null);
chronometer = (Chronometer)
inflatedView.findViewById(R.id.chronometer);
if (userList.size() != 0) {
//Set the User Array list in ListView
adapter = new SimpleAdapter(getApplicationContext(), userList, R.layout.payement_timing_list_adapter_view,
new String[]{"Driver_fullname", "plate_no", "parking_name"},
new int[]{R.id.drivername, R.id.plateno, R.id.pname});
myList.setAdapter(adapter);
}
myList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
Log.d("My POSITION",""+position);
((Chronometer)inflatedView.findViewById(R.id.chronometer)).myList.
(position).start();
chronometer.start();
}
});
You will need to use a custom adapter for your ListView, and declare the Chronometer in the getView method for each row.
A custom adapter could be onle like this:
public class CustomAdapter extends BaseAdapter{
ArrayList<HashMap<String, String>> users;
Context context;
private static LayoutInflater inflater=null;
public CustomAdapter(MainActivity mainActivity, ArrayList<HashMap<String, String>> usersList) {
// TODO Auto-generated constructor stub
users = usersList;
context=mainActivity;
inflater = ( LayoutInflater )context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return items.length;
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public class Holder
{
TextView tv;
...
Chronometer cr;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Holder holder=new Holder();
View rowView;
//Create a custom layout for your row view with the chronometer on it and get it here
rowView = inflater.inflate(R.layout.custom_row_item, null);
holder.tv=(TextView) rowView.findViewById(R.id.textView1);
...
holder.cr=(Chronometer) rowView.findViewById(R.id.chronometer);
cr.start();
holder.tv.setText("GET THE TEXT YOU NEED FROM USERS LIST HERE");
return rowView;
}
}
Then declare and use your custom adapter like:
CustomAdapter myAdapter = new CustomAdapter(YourActivity.this, userList);
myList.setAdapter(myAdapter);
Hope it helps :)

Which event is called when user exits spinner

I have a spinner and I want to show/hide something when the user exits the spinner without doing any thing. for example, when the user touches an area outside the spinner.
p.s. the onTouchEvent for the container layout (LinearLayout in my case) is also not called.
here is my implementation for the custom spineer:
public SpinnerHintAdapter(Activity context, int resourceId, int textViewId, List<SpinnerItem> list, Spinner parent){
super(context,resourceId,textViewId, list);
flater = context.getLayoutInflater();
this.items = list;
this.gender = parent;
}
#Override
public int getCount() {
return items.size();
}
#Nullable
#Override
public SpinnerItem getItem(int position) {
return items.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
SpinnerItem spinnerItem = getItem(position);
View rowView = flater.inflate(R.layout.gender_item ,null,true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.main_text);
txtTitle.setText(spinnerItem.getName());
txtTitle.setTextColor(txtTitle.getResources().getColor(R.color.color_white));
Log.i(Tags.byEmail, "VVVVVVVVVVVVv");;
gender.setVisibility(View.VISIBLE);
return rowView;
}
#Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
firstTime = false;
SpinnerItem rowItem = getItem(position);
View rowView = flater.inflate(R.layout.gender_drop_down_item ,null,true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.drop_down_text);
txtTitle.setText(rowItem.getName());
if(!isEnabled(position)){
txtTitle.setBackground(txtTitle.getResources().getDrawable(R.drawable.normal_rounded_text_field));
txtTitle.setTextColor(Color.parseColor("#777777"));
}
parent.setBackground(parent.getResources().getDrawable(R.drawable.normal_rounded_text_field));
txtTitle.setEnabled(isEnabled(position));
gender.setVisibility(View.INVISIBLE);
Log.i(Tags.byEmail, "DDDDDDDDDDDDDDDDDD");
return rowView;
}
#Override
public boolean isEnabled(int position) {
if(position == 0)
return false;
return super.isEnabled(position);
}
}
when the user exits without selecting an item the getView function is not called and hence the gender (is the spinner object itself) will not be visible.
I tried OnItemSelected and OnNothingSelected are also not called.
event OnTouch events are not called.
The following Events are not called when the user exits:
1- OnItemSlected
2- OnNothingSelected
3- OnFocusChanged.
4- OnTouch
I think that's event will work for you as magic, no?
public class CustomSpinner extends Spinner {
... Constructors ...
#Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
Log.d(CustomSpinner.class.getSimpleName(), "onWindowFocusChanged: " + hasWindowFocus);
if (hasWindowFocus) {
// User click out of window
} else {
// User click in spinner window
}
}
}
With a Spinner you set an AdapterView.OnItemSelectedListener which implements two methods; onItemSelected and onNothingSelected.
Like this:
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// This is called when the user selects an item in the Spinner
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
// This is called when the user closes the spinner selecting nothing
}
});

method "onItemSelected" doesn't work in array adapter and also in fragment

The method onItemSelected doesn't work and I don't know why.
Below is my code.
Array adapter:
public class MyListAdapter extends ArrayAdapter {
Spinner spinner;
ListView listView;
/*public MyListAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
}*/
public MyListAdapter(Context context) {
super(context, R.layout.single_listview_item);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
spinner = (Spinner) convertView.findViewById(R.id.simpleSpinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
getContext(),
R.array.country_arrays,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
System.out.println("ciao1");
// spinner.setOnItemSelectedListener(this);
return row;
}
/* #Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selState = (String) spinner.getSelectedItem();
System.out.println(selState);
Toast.makeText(
getContext(),
"Clicked on Planet: " + selState + "", Toast.LENGTH_SHORT).show();
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}*/
}
fragment:
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_list2, container, false);
listView = (ListView) rootView.findViewById(R.id.listview);
ListAdapter listAdapter = new MyListAdapter(getContext());
listView.setAdapter(listAdapter);
// listView.setOnItemClickListener(this);
listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> parent, View view, int position, long i)
{
listView.setSelection(position);
String selState = (String) listView.getSelectedItem();
Toast.makeText(
getContext(),
"Clicked on Planet: " + selState + "", Toast.LENGTH_SHORT).show();
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
On ListViews you use onItemClicked. OnItemSelected is for Spinners. It's one of those Android nuisances...
In your method of setting OnItemSelectedListener(this) within the ArrayAdapter, I believe the issue is that, because every spinner in the list references the same instance of MyListAdapter, your OnItemSelected method is not distinguishing which spinner within your list was actually selected from-- it just references the spinner object that was last set to the MyListAdapter.spinner reference, which should be the last one in the list.
To remedy this, don't use spinner.getSelectedItem(). Instead use ((Spinner) parent).getSelectedItem(), since the parent object will be the actual spinner selected from. And at that point, you should make the spinner variable local to the getView method.
In the method of calling listView.setOnItemSelectedListener(...) in the fragment, I expect you meant to have listView.setOnItemClickListener(...), but that will listen for a click on a row in your list, not a selection from a spinner.
To detect a selection from one of your spinners, make the first modification above. To detect a click on a row in your listView as well, change to listView.setOnItemClickListener. Without more context for your objective or the actual errors occurring, it's hard to tell if both or just the first is desired.
EDIT:
From your comments, I think you should have this in your MyListAdapter:
public class MyListAdapter extends ArrayAdapter implements AdapterView.OnItemSelectedListener {
public MyListAdapter(Context context) {
super(context, R.layout.single_listview_item);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
Spinner spinner = (Spinner) row.findViewById(R.id.simpleSpinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
parent.getContext(),
R.array.country_arrays,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
return row;
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selState = (String) ((Spinner) parent).getSelectedItem();
System.out.println(selState);
Toast.makeText(
parent.getContext(),
"Clicked on Planet: " + selState + "", Toast.LENGTH_SHORT).show();
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
And this in your fragment (no listeners):
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_list2, container, false);
listView = (ListView) rootView.findViewById(R.id.listview);
ListAdapter listAdapter = new MyListAdapter(getContext());
listView.setAdapter(listAdapter);

How to get item value in a listview in android?

I have referenced to a tutorial and I have created a custom list view in fragment, but I am unable to get the position or value of any item on item click of list view. I want to show a toast containing the position of the item. I don't know how to implement that.
CustomListAdapter.java
public class CustomListAdapter extends BaseAdapter{
private ArrayList<MyActivityAdapterItem> listData;
private Context context;
//private LayoutInflater layoutInflater;
public CustomListAdapter(Context context, ArrayList<MyActivityAdapterItem> listData) {
this.listData = listData;
this.context = context;
}
#Override
public int getCount() {
return listData.size();
}
#Override
public Object getItem(int position) {
return listData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
//ViewHolder holder;
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_row_layout, null);
// holder = new ViewHolder();
//convertView.setTag(holder);
}
TextView headingView = (TextView) convertView.findViewById(R.id.title);
TextView placeView = (TextView) convertView.findViewById(R.id.place);
TextView reportedDateView = (TextView) convertView.findViewById(R.id.date);
headingView.setText(listData.get(position).getHeading());
placeView.setText("At, " + listData.get(position).getPlace());
reportedDateView.setText(listData.get(position).getDate());
return convertView;
}
}
FindPeopleFragment.java
public class FindPeopleFragment extends Fragment implements OnClickListener {
AlertDialog.Builder builder ;
ListView lv1;
ImageButton delall;
CharSequence options[] = new CharSequence[] {"Delete"};
ArrayList details;
CustomListAdapter ad1;
String msg="abc";
public FindPeopleFragment(){}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_find_people, container, false);
delall=(ImageButton) rootView.findViewById(R.id.deleteall);
details = getListData();
lv1 = (ListView) rootView.findViewById(R.id.activitylist);
ad1=new CustomListAdapter(getActivity(), details);
lv1.setAdapter(ad1);
builder= new AlertDialog.Builder(getActivity());
delall.setOnClickListener(this);
lv1.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
//Toast.makeText(getActivity(), , Toast.LENGTH_LONG).show();
/*Bundle args = new Bundle();
args.putString(MyActivitiesFragment.MSG, msg);
MyActivitiesFragment f1=new MyActivitiesFragment();
f1.setArguments(args);
MainActivity.fm.beginTransaction().replace(R.id.frame_container,f1).commit();*/
}
});
return rootView;
}
The position of the clicked item in a ListView can be retrived easily on the onItemClick method as you can see in the 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.
So in your case, the position of the clicked item is the arg2 value. Your code should be like this:
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getActivity(), arg2+"", Toast.LENGTH_LONG).show();
/*...*/
}
EDIT:
To get the Item, you can do like this:
(Item) arg0.getAdapter().getItem(arg2);
TL;DR
You can see in this case that it is important to use good names for parameters. With the default names given by Eclipse - or by others IDEs - this line:
(Item) arg0.getAdapter().getItem(arg2);
looks pretty strange. But if you are using the Android names - which gives you onItemClick(AdapterView<Item> parent, View view, int position, long id) - the line becomes:
(Item) parent.getAdapter().getItem(position);
Which is clearer and easier to use.
this should work:
lv1.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
Toast.makeText(getApplicationContext(), "Selected item at position: " + position, Toast.LENGTH_LONG).show();
}
}
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent i1 = new Intent(getApplicationContext(), Plaeeng.class);
// List<ScanResult> wifiList;
// i1.putExtra("cuor", );
// startActivity(i1);
Toast.makeText(ListCours.this, "=>"+parent.getAdapter().getItem(position), 5000).show();
}
});
You are doing well in setOnItemClickListener
the problem its the autocomplete its not working well in parameters you should have something like this:
lv1.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
}
});
the position is in your arg2, and as a tip you can get the item you click using this snippet:
parent.getAdapter().getItem(position);

ListView Updating a single row

I want to update a single row in my listview with different content once i press a button. I know i can use notifydatasetchanged() but that would update the whole listView.
I have read this answer and it fits perfectly for what I want to do.
I have done a listview with 5 rows and when I press the button I want to update the 4th row with a different text. I dont want to set the text programatically since this is just a dummy project just to see if refreshing a single row is possible and my real project is much more complex than just a textview.
So my question is: can i use getView() to update a single row in a listview?
Here is my code:
my Activity:
public class MainActivity extends Activity {
public ListView list1;
public listAdapter adapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list1 = (ListView) findViewById(R.id.my_list);
adapter = new listAdapter(this);
list1.setAdapter(adapter);
Button button1 = (Button) findViewById(R.id.my_button);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
adapter.setText("Different text");
View row2Update = list1.getChildAt(3);
list1.getAdapter().getView(3, row2Update, list1);
}
});
}
}
My adapter :
public class listAdapter extends BaseAdapter{
public Activity activity;
public String text="Normal Text";
public listAdapter(Activity activity){
this.activity = activity;
}
public void setText(String text){
this.text = text;
}
public int getCount() {
return 5;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout rowView = (LinearLayout) inflater.inflate(R.layout.row_layout, null);
TextView textView = (TextView) rowView.findViewById(R.id.row_text);
textView.setText(text);
return rowView;
}
}
This is what the activity looks like:
But when I press my button nothing changes
You cannot call the getView() method of the adapter yourself. The adapter's getView() method is is only called, when
The listview is create
when the user scrolls the list view
when notifysetdatachanged() is called.
All these are done by the OS. GetView() is called for all the rows in the listview. It is not called for just a single row. So, if you want to change the rows, you have to provide the data again in a String[], ArrayList<> etc
If you want different text to appear for for a single row, onClick() of a button - you can do this
public class listAdapter extends BaseAdapter{
public Activity activity;
public ArrayList<String> text;
public listAdapter(Activity activity){
this.activity = activity;
}
public void setText(ArrayList<String> text){
this.text = text;
}
public int getCount() {
return 5;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout rowView = (LinearLayout) inflater.inflate(R.layout.row_layout, null);
TextView textView = (TextView) rowView.findViewById(R.id.row_text);
textView.setText(text[position]);
return rowView;
}
}
And in your Activity :
list1 = (ListView) findViewById(R.id.my_list);
adapter = new listAdapter(this);
String[] entries={"Normal Text","Normal Text","Normal Text","Normal text","Normal text"};
ArrayList<String> text=Arrays.asList(entries);
adapter.setText(text);
list1.setAdapter(adapter);
Button button1 = (Button) findViewById(R.id.my_button);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
text.set(3,"Different Text");
adapter.setText(text);
list1.setAdapter(adapter);
}
});
There is another way of doing it also as #Andy suggested in one of the comments :
listViewPeople.setOnItemClickListener(new ListView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> a, View v, int position, long l) {
//IF YOU WANT TO CHANGE THE CONTENT OF THE ROW CLICKED
if(position == someNumber) {
text.set(position,"different Text");
list1.setAdapter(text);
}
}
});
Sorry for the bold text. For some reason the CTRL+K is not working for the above code.

Categories

Resources