Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 865273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:36:57+00:00 2026-05-15T09:36:57+00:00

Hallo all, I have a ListView which contains a Button in each line. The

  • 0

Hallo all,

I have a ListView which contains a Button in each line. The following code is part of the getView() Method

public View getView(final int position, View convertView, ViewGroup parent) {
        View row = convertView;
        TextView tv;
        Button saveA_button;
        EditText edittext;
        FITB_ViewWrapper wrapper;

  if (row == null) {
       LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       if (ChooseMode_Act.modeInfo.equalsIgnoreCase("Training")) { 
             row = li.inflate(R.layout.exercise_for_training_fitb,parent, false);
       }else {
              row = li.inflate(R.layout.exercise_for_exam_fitb,parent, false);
       }
       wrapper=new FITB_ViewWrapper(row);
       row.setTag(wrapper);
       if (ChooseMode_Act.modeInfo.equalsIgnoreCase("Exam")) {
           saveA_button=wrapper.getSaveAnswer_Button();
           OnClickListener l=new OnClickListener() {

               @Override
               public void onClick(View v) {
                     Integer mp=(Integer)v.getTag();
                     Log.i("mp","my Position is: "+mp);
               }
          };
          saveA_button.setOnClickListener(l);
       }
   }else {
           wrapper=(FITB_ViewWrapper) row.getTag();
 }

For my App i need to known to which item the Button belongs to, so i try to detect it. The code

Log.i("mp","my Position is: "+mp);

puts out a message: mp myPosition is: null

I can’t understand, why do i get a “null” but not an Integer? How can i find out the Position of an Item in a ListView?

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:36:58+00:00Added an answer on May 15, 2026 at 9:36 am

    Log.i(“mp”,”my Position is: “+position);

    you have the position already !

    public View getView(final int position, View convertView, ViewGroup parent) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hallo all, I have a ListView, which contains an EditText in each of it's
hallo all i have an asp.net site which i have no source code for
Hello all i have the code below which produces four wheels each with the
Problem Hello all! I have this code which takes my jpg image loops through
hallo all i have a site which has a very big scroll on it,
Button createEventButton = (Button)findViewById(R.id.NewEventButton); Button createPageButton = (Button)findViewById(R.id.NewPageButton); Hallo I have searched all over
Hallo all. if i have week number 42 and i need to know what
hello all I have a small dialog which I created dynamically, which has a
hello all i am working on a project in which i have a webpage
Hello I currently have this code checking if a cookie exists, it works all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.