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

Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hullo all, Wondering if there are any Java hackers who can clue me in
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
All of my users are a short walk down the hall, and all of
All of my codes fail. They should print he, hello and 5 \n 3,
Hallo, i am using WSS 3.0 and i need to display certain entries of
Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility.
Hallo, i need to write some javascript that gets the contents of a userfield
I.e.: echo H#97llo | MagicPerlCommand Stdout: Hallo were MagicPerlCommand is something like perl -pnle

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.