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

  • Home
  • SEARCH
  • 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 7870919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:45:18+00:00 2026-06-03T01:45:18+00:00

A have to customize standard ListView control in my application. I viewed video tutorials

  • 0

A have to customize standard ListView control in my application.

I viewed video tutorials by Lynda.com for this and do everything they showed.

My Activity Layout:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:background="#ffffff">

<ListView
    android:id="@+id/menuList"
    android:layout_width="match_parent"
    android:layout_height="500dp"
    android:layout_x="0dp"
    android:layout_y="210dp"
    android:footerDividersEnabled="false">
</ListView>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="250dp"
    android:layout_height="110dp"
    android:layout_x="115dp"
    android:layout_y="100dp"
    android:src="@drawable/deserts_log" />

<ImageView
    android:id="@+id/deserts_home_btn"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_x="20dp"
    android:layout_y="20dp"
    android:src="@drawable/green_home" />

</AbsoluteLayout>

My custom listView row layout:

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

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

<TextView
    android:id="@+id/custom_menu_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</LinearLayout>

So I create my own LiasAdapter class:

public class MyAdapter extends ArrayAdapter<String>
{
    public MyAdapter(Context context, int resource, int textViewResourceId,
            List<String> objects) {
        super(context, resource, textViewResourceId, objects);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.custom_menu_row, parent);
        String[] data = {"Десерт 1", "Десерт 2", "Десерт 3"};
        ImageView iv = (ImageView)row.findViewById(R.id.custom_menu_item);

        if(data[position]=="Десерт 1")
        {
            iv.setImageResource(R.drawable.desert1);
        }

        if(data[position]=="Десерт 2")
        {
            iv.setImageResource(R.drawable.desert2);
        }

        if(data[position]=="Десерт 3")
        {
            iv.setImageResource(R.drawable.desert3);
        }
        return row;
    }
}

Now it doesn matter how I create a structure of my List, so there are some “hardcoding” )).

I set this adapter for my ListView control:

listView = (ListView)findViewById(R.id.menuList);
    MyAdapter adapter = new      MyAdapter(this,R.layout.custom_menu_row,R.id.custom_menu_text,data);
    listView.setAdapter(adapter);

So, “data” is valid ArrayList collection. It builds withiut errors, but when I tryed to start this activity it crashes with such message: " E/AndroidRuntime(495): java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView"

If anybody has already met this problem? In video tutorial custom listView works great, but my doesn’t :((

  • 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-03T01:45:21+00:00Added an answer on June 3, 2026 at 1:45 am

    Replace below code

    View row = inflater.inflate(R.layout.custom_menu_row, parent);
    

    with

     View row = inflater.inflate(R.layout.custom_menu_row, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to customize a django application to have accept localized date format
I have tons of ajax components on this booking engine. I need to customize
Currently i am working on a iPhone Application Which is displaying video. I have
I have edited the standard GroupBox template as I wanted to customize it. Apart
I have an application that uses Spring Security to control access to pages, to
In my application, I am using a listview and have customized the associated array
Does any one have tried to customize default section index displayed in UITableView. I
I have a subclass of NSWindow to customize one of my windows for my
I have a class A that inherits UITableViewCell (to customize a table cell). It
We have a web portal product from which we customize portals from customers. We

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.