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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:11:03+00:00 2026-05-22T17:11:03+00:00

I’m having trouble with the setListAdapter(). It tells me to just create the method

  • 0

I’m having trouble with the setListAdapter(). It tells me to just create the method because it doesn’t know anything about it. I’m, for now, just trying to get a list to populate and I don’t even know what this code is doing.

public class PassScreen extends Activity {
TextView selection;
ArrayList<String> items = new ArrayList<String>();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.passwordscreen);
    selection=(TextView)findViewById(R.id.selection);

    try { 
        InputStream in=getResources().openRawResource(R.raw.words);
        DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = builder.parse(in,null);
        NodeList words=doc.getElementsByTagName("word");
        for (int i =0;i<words.getLength();i++){
            items.add(((Element)words.item(i)).getAttribute("value"));
        }
        in.close();
    }
    catch (Throwable t){
        Toast.makeText(this, "Exception: " + t.toString(), 2000).show();
    }

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

}
public void onListItemClick(ListView parent, View v, int position, long id){
    selection.setText(items.get(position).toString());
}
}

As you can see I have and xml file that I’m using. That looks just like what the book looks like but then again I copy and pasted the setListAdapter() so I guess that’s not all that helpful.

If you could also show me what the setListAdapter() is doing that would be great. I can’t seen to understand what google is talking about.

Here is the 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">

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

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

</LinearLayout>

And some of the words xml:

<words>
<word value="lorem"/>
<word value="ipsom"/>
<word value="dolor"/>
</words>

Also can you explain what’s going on? I don’t understand the setListAdapter() at all. Or just point to Googles white paper. I can’t find it. It’s not like I know how to look that stuff up anyway.

  • 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-22T17:11:04+00:00Added an answer on May 22, 2026 at 5:11 pm

    setListAdapter() isn’t a method you can call on an Activity (it is available on ListActivity but you’re not using that). You’re going to have to add a ListView into your layout (/res/layout/passwordscreen) and then find it and call setAdapter on that.

    e.g.

    ListView lv = (ListView) findViewById(R.id.mylistview);
    lv.setAdapter(.....);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm trying to create an if statement in PHP that prevents a single post
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.