In general, there is a ListView
list that I fill out through the SimpleCursorAdapter
. It is initialized like this:
String[] from = new String[] {"client_tel","timeToWashStart"}; int[] to = new int[] {R.id.client_tel,R.id.timeToWashStart}; scAdapter = new SimpleCursorAdapter(MainActivity.this, R.layout.item, null, from, to, 0); lvData.setAdapter(scAdapter); getSupportLoaderManager().initLoader(0, null, MainActivity.this);
I receive the data through CursorLoader
with MySQL
, the list is formed, everything is fine. But in each row of the list there are buttons to click on.
Here's the question: how do you know the _id or position of the line where the button was clicked?
and the method
lvData.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(MainActivity.this, "position = " + position + " id= " + id, Toast.LENGTH_SHORT).show(); } });
for some reason it does not work ... and I just won’t understand how to set the getView()
method for the adapter.
Tell me which way to think, I'm already tired of stomping around) Thank you in advance for your advice.
PS: all my code is implemented in one class, maybe this is important
public class MainActivity extends FragmentActivity implements CompoundButton.OnCheckedChangeListener,LoaderManager.LoaderCallbacks<Cursor> {