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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:32:33+00:00 2026-05-16T12:32:33+00:00

I’m doing an admin page that can view the users that exist in the

  • 0

I’m doing an admin page that can view the users that exist in the system. My idea is to show a list of the users and the details in one page. I heard that using listview is very tedious. Is there any other way that is easy?

Maybe view in textview but I dont know how it works. I must put in a lot of textview on my xml?

A simple task that I need to know how to do. I just need to know how to view datas in a page, using any method.

Thank you very much! Hope to get responds soooon! =D

Dayne


Hello again

Here’s how a listview looks like:

package log1.log2;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class AdminMain extends ListActivity {


static final String[] COUNTRIES = new String[] {
"Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands","Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru"
  };


@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

  ListView lv = getListView();
  lv.setTextFilterEnabled(true);

  lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
      // When clicked, show a toast with the TextView text
      Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
          Toast.LENGTH_SHORT).show();
    }
  });
}

For the code above, the data is written in the codes itself. My data is in my database and I need it to be shown on the listview. I do not know how to do it. I tried a few ideas I had:

public class AdminMain extends ListActivity {

    DBAdapter db = new DBAdapter(this);

    private String TEST;




    public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          db.open();
          Cursor c = (Cursor) db.getAllUser();  
          final String[] COUNTRIES = new String[] {

            };


        TEST=c.getString(1).toString();

          setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, TEST));
          getListView().setTextFilterEnabled(true);

    }

}

I declare a string and I tried retrieving data from database and save it to the string which is TEST. And then I tried showing it on the listview :

setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, TEST));
              getListView().setTextFilterEnabled(true);

But I cant put ‘TEST’ in the listview. The error, The constructor ArrayAdapter<String>(AdminMain, int, String) is undefined. will appear.

I hope somebody will give me a good answer for this. I’m looking forward to your replies. Thank you for taking your time reading this.

-Dayne


Hello Sephy

Here’s what I edited.

public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          db.open();
          Cursor c = (Cursor) db.getAllUser();  
          /*final String[] COUNTRIES = new String[] {

            };*/

          final String[] TEST = c.getString(1);

        //TEST[]=c.getString(1).toString();

          setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1));
          getListView().setTextFilterEnabled(true);

    }

As you can see I tried to put data from my database straight into the array but it can’t work; final String[] TEST = c.getString(1);. The error message Type mismatch: cannot convert from String to String[] appeared.

  • 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-16T12:32:34+00:00Added an answer on May 16, 2026 at 12:32 pm

    ListView is tedious to use, but sometimes, if for instance your dataset is quite big and repetitive, you might want to consider using ListView.
    If you still don’t want to, you can create a ScrollView plus a header in a TextView in your xml for instance, and then in your java, you use a for loop or a while to loop on your database result, and every time you have one set of data ready, you create a new TextView and add it to the ScroolView. It would be something like that :

    if (yourCursor.moveToFirst()) {
    do {
          //prepare your data       
          TextView tv = new TextView(yourContext);
          tv.setText("yourData");
          // you can set id, tag, text color, font, ...
          yourScrollView.addView(tv);
        } while (yourCursor.moveToNext());
    }
    yourCursor.close();
    yourDB.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.