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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:00:37+00:00 2026-05-21T21:00:37+00:00

I created an Adapter to populate my custom listView and when ran on the

  • 0

I created an Adapter to populate my custom listView and when ran on the emulator the activity is blank. Plz help. I am sure I’m missing something ’cause I am new to java & Android. Some code snippets to correct it and pointers will be appreciated. Thnx!

My Activity:

public class List_AC3 extends ListActivity {

/**
 * -- Called when the activity is first created
 * ===================================================================
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.list_view2);

    displayResultList();
}

private void displayResultList() {
    Cursor databaseCursor = null;
    DomainAdapter databaseListAdapter = new DomainAdapter(this, R.layout.list_item, databaseCursor, 
            new String[] {"label", "title", "description"}, 
            new int[] { R.id.label, R.id.listTitle, R.id.caption });
            databaseListAdapter.notifyDataSetChanged();
            setListAdapter(databaseListAdapter);
}
}

My Adapter:

public class DomainAdapter extends SimpleCursorAdapter{

private LayoutInflater mInflater;
String extStorageDirectory;

public DomainAdapter(Context context, int layout, Cursor c, String[] from,
        int[] to) {
    super(context, layout, c, from, to);
        mInflater = LayoutInflater.from(context);
}

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

    ViewHolder holder;

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.list_item, null);

        holder = new ViewHolder();
        holder.text1 = (TextView) convertView.findViewById(R.id.label);
        holder.text2 = (TextView) convertView.findViewById(R.id.listTitle);
        holder.text3 = (TextView) convertView.findViewById(R.id.caption);

        convertView.setTag(holder);

    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File dbfile = new File(extStorageDirectory+ "/Aero-Technologies/flyDroid/dB/flyDroid.db");
    SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
    Cursor data = db.rawQuery("SELECT * FROM AC_list", null);

    data.moveToPosition(position);

    int label_index = data.getColumnIndex("label"); 
    String label = data.getString(label_index);

    int title_index = data.getColumnIndex("title"); 
    String title = data.getString(title_index);

    int description_index = data.getColumnIndex("description"); 
    String description = data.getString(description_index);

    holder.text1.setText(label);
    holder.text2.setText(title);
    holder.text3.setText(description);

    return convertView;
    }

    static class ViewHolder {
        TextView text1;
        TextView text2;
        TextView text3;
    }  
}

The list_view2.xml:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" 
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="30dip" 
    android:padding="4dip"
    android:background="@drawable/gradient" >

    <ImageButton
        android:id="@+id/homeBtn"
        android:src="@drawable/ic_menu_icon"
        android:layout_width="wrap_content" 
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:background="@null" />

    <TextView
        android:id="@+id/titleBarTitle"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content" 
        android:layout_height="match_parent"
        android:textSize="18sp" />

    <ImageButton
        android:id="@+id/toolBtn"
        android:src="@drawable/ic_menu_list"
        android:layout_width="wrap_content" 
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:background="@null" />

</RelativeLayout>

<ListView 
   android:id="@id/android:list" 
   android:layout_height="wrap_content"
   android:layout_width="fill_parent" />

</LinearLayout>

And my list_item.xml:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/acItem"
style="@style/listItem" >

<TextView
    android:id="@+id/label"
    style="@style/listAcronym" />

<TextView
    android:id="@+id/listTitle"
    style="@style/listTitle" />

<TextView
    android:id="@+id/caption"
    style="@style/listDiscription"/>        

<ImageView
    style="@style/listNextIcon" />   

</RelativeLayout>
  • 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-21T21:00:37+00:00Added an answer on May 21, 2026 at 9:00 pm

    The correct answer can be found HERE along with the code.

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

Sidebar

Related Questions

I created custom adapter for listview which contain text and images, on click of
I have created a custom Base Adapter class, to populate a list view with
I am attempting to create a custom Adapter for my ListView since each item
I have a Listview with custom cursor adapter. I'm trying to prevent input in
I create a dialog and populate it with a listview that uses a custom
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I've created a custom adapter for my spinner because I wanted to have multiple
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I
What I'm essentially trying to do is to populate my ListView with colored TextViews.
I am using the following piece of code to populate my ListView - setListAdapter(new

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.