K
K
kvaks2020-02-26 11:56:51
Android
kvaks, 2020-02-26 11:56:51

How to get text in ListView when clicked?

There is a code from examples, tell me how to get the text that was clicked.

lvMain.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {
        Log.d(LOG_TAG, "itemClick: position = " + position + ", id = "
            + id);
      }
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2020-02-27
@YuryBorodkin

a list (ArrayList) of data is passed to the adapter, position corresponds to the index in this list. By requesting data on the index, you can understand where the click was.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question