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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:39:12+00:00 2026-06-05T19:39:12+00:00

I want to create a listview that immediately when initialized in the onCreate() method

  • 0

I want to create a listview that immediately when initialized in the onCreate() method will add images ONLY to certain fields, And i have no idea how to do this.

Here is the necessary part of my onCreate() method:

((ListView) findViewById(android.R.id.list)).setClickable(true);
    for(int i=0; i<num_enter; i++){
    adapter=new SimpleAdapter(this, listItems, R.layout.custom_row_view,new String[]{"name", "current", "image"},  new int[] {R.id.text1, R.id.text2, R.id.lockImage});
    setListAdapter(adapter);
    HashMap<String,String> temp = new HashMap<String,String>();
    temp.put("name", name[i]);

    SetSql getport = new SetSql(this);
    getport.open();
    int port = getport.getSingleProtect(i);
    getport.close();
    if(port==1){
        //THIS IS WHERE I WANT TO SET THE IMAGE

        temp.put("current", Integer.toString(current[i]));
    }else{
    temp.put("current", Integer.toString(current[i]));
    }
    listItems.add(temp);
    adapter.notifyDataSetChanged();
    }
    }else{
        ((ListView) findViewById(android.R.id.list)).setClickable(false);
        adapter=new SimpleAdapter(this, listItems, R.layout.custom_row_view,new String[]{"name", "current"},  new int[] {R.id.text1, R.id.text2});
        setListAdapter(adapter);
        HashMap<String,String> temp = new HashMap<String,String>();
        temp.put("name", "You have no enteries yet!");
        temp.put("current", "");
        listItems.add(temp);
        adapter.notifyDataSetChanged();
    }

Here is my custome_row_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<ImageView 
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/lockImage"
/>

<TextView android:id="@+id/text1" 
android:textSize="25dp"  
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

<TextView android:id="@+id/text2"
android:textSize="25dp" 
android:layout_marginTop="5dp"
android:layout_width="wrap_content" 
android:layout_height="fill_parent"
android:layout_alignParentRight="true"/>

</RelativeLayout> 

Thanks for any help!!!

  • 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-05T19:39:13+00:00Added an answer on June 5, 2026 at 7:39 pm

    I think you should make new xml file to in record you want to add Image. Your listView like category ListView. I have an ideal for you

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder holder;
         convertView = null;
        holder = new ViewHolder();
        int port = getport.getSingleProtect(position);
        if(port==1){
        //INFLATE YOUR IMAGE
            convertView = inflater.inflate(INFLATE_YOUR_IMAGES, null);
            convertView.setTag(holder);
            .......................
    
    
    
    
        }else {
            .................
            //INFLATE AS NORMAL
        }
    
    
        return convertView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView that I want to use with an ArrayAdapter to add
I have create android listview that fill in using String array. I want to
ASP.Net 3.5 I want to create a user control that contains the ListView and
i want create image animation , i have 50 images with png format now
I want to create demo app that calculate prize of content in listview. User
I want to create an informative app that will display a list of content.
I have a ListView in which i want to create an event when the
The context: I want to have a ListView that wouldn't receive focus (e.g. won't
What I want to create is a list view that will resize itself in
I want to create a listview type user control which'll have a picturebox and

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.