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 8033001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:33:36+00:00 2026-06-05T01:33:36+00:00

I have an Activity which also has a ListView in it. I’m loading some

  • 0

I have an Activity which also has a ListView in it. I’m loading some EditText boxes, buttons, etc to that ListView in my getView method.

if(position==0)
            {
                ((TextView)convertView.findViewById(R.id.textview_settings)).setText("User Information");

            }
            else if(position==1 || position==2 || position==5 || position==6 || position==7 || position==10 || position==13)
            {
                ((LinearLayout)convertView.findViewById(R.id.linear_settings)).setVisibility(View.VISIBLE);
                ((RelativeLayout)convertView.findViewById(R.id.Relative_home)).setVisibility(View.GONE);

                if(position==1 || position==5 || position==5)
                    ((EditText)convertView.findViewById(R.id.edittext_settings)).setBackgroundResource(R.drawable.f_t_1_iphone);
                else if(position==7 || position==2)
                    ((EditText)convertView.findViewById(R.id.edittext_settings)).setBackgroundResource(R.drawable.f_t_3_iphone);
                else if(position==6)
                    ((EditText)convertView.findViewById(R.id.edittext_settings)).setBackgroundResource(R.drawable.f_t_2_repeat_iphone);
                else if(position==13 || position==10)
                    ((EditText)convertView.findViewById(R.id.edittext_settings)).setBackgroundResource(R.drawable.f_t_4_iphone);    
            }

And in multiple instances I’m also adding a Button to the same List. Basically, I’m just loading a particular layout file to a particular row based on the row index of the ListView. The button has the id button_title – defined in my xml below.

    convertView = mInflater.inflate(R.layout.next, null); *//inside getView method*

Contents of next.xml:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/linear">

    <FrameLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/frame_settings">

    <RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/Relative_home"
    android:orientation="horizontal" >
    <TextView
        android:id="@+id/textview_settings"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center|left"
        android:layout_margin="5dp"
        android:text=""
        android:textSize="15dp"
        android:textStyle="bold"
        android:typeface="sans" android:layout_alignParentLeft="true"/>

     <ImageButton
        android:id="@+id/Button_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:layout_marginRight="10dp"
       android:background="@drawable/edit_button_pressed" android:layout_alignParentRight="true"/>
     </RelativeLayout>

     <LinearLayout
        android:id="@+id/linear_settings"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">       
        <EditText
        android:id="@+id/edittext_settings"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:textStyle="bold"
        android:typeface="sans" android:layout_alignParentLeft="true"/>
        </LinearLayout>
     </FrameLayout>
     </LinearLayout>

Now, since I have multiple instances of the same button within this activity, I’m not able to assign unique IDs to each of these buttons. All buttons technically now hold the same ID.

Is there any way in which I can assign different IDs to each of these buttons? Programmatically?

  • 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-06-05T01:33:39+00:00Added an answer on June 5, 2026 at 1:33 am

    You need to use findViewById on the buttons parent layout in order to change the id on the specific button.

    Egs:

    convertView = mInflater.inflate(R.layout.next, null);
    Button buttonIWantToChangeID = convertView.findViewById(R.whatever.Button_title);
    buttonIWantToChangeID.setId(1000+listPosition);
    

    Notice findViewById is used on the convertView…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity which consists of a ListView . The problem is that
I have an activity which has two edit text fields: one for the title
i have a activity which extends ListActivity. The Layout contains some generic widget an
I have an Activity which extends ExpandableListActivity and which contains some Parent Groups and
I have an Activity which has an 'OK' button. And I have an 'Edit'
I have an activity which shows some List entries. When I click on a
I know that Android doesn't have an Application-level onPause the way an Activity has
My current application has one Activity, the main one which extends ListActivity (listview of
I have an app which has 3 dashboard items as an activity. So whenever
I have made an application which has tabs like in HelloTabActivity, there is also

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.