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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:01:28+00:00 2026-06-03T04:01:28+00:00

I have an array in my resources that I want to display in a

  • 0

I have an array in my resources that I want to display in a ListView but I’m failing miserably so maybe someone can tell what I’m doing wrong and what should I do to accomplish this. Here is the code I’ using:

In my XML resource:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">myApp</string>
<string-array name="EstadosArray">
    <item >Estado1</item>
    <item >Estado2</item>
    <item >Estado3</item>
    <item >Estado4</item>
    <item >Estado5</item>
    <item >Estado6</item>        
</string-array>
</resources>

In my Activity:

public class myMain extends Activity{
String[] Estados;
eAdapter ea=null;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

    Estados = getResources().getStringArray(R.array.EstadosArray);
    ea = new eAdapter();
    ListView EstadosList = (ListView) findViewById(R.id.estadosList);
    EstadosList.setAdapter(ea);

}

class eAdapter extends ArrayAdapter<String> {
    eAdapter() {
            super(myMain.this, android.R.layout.simple_list_item_1, Estados);
            }
    public View getView(int position, View convertView, ViewGroup parent) {
        eHolder holder;
        if (convertView == null) {
            LayoutInflater inflater = getLayoutInflater();
            convertView = inflater.inflate(R.layout.esatdoitem, null);
            holder = new eHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (eHolder) convertView.getTag();
        }
        holder.populateFrom(Estados.get(position));  // HERE IS WHERE I HAVE THE issue is, I DON'T KNOW HOW TO GET THE POSITION, IS GIVING ME AN ERROR (CANNOT INVOKE GET(INT) ON THE ARRAY TYPE STRING[])
        return (convertView);
    }

}
class eHolder{
    public TextView esname=null;
    eHolder(View row) {
        esname = (TextView) row.findViewById(R.id.ename);
    }
    void populateFrom(String est) {
        esname.setText(est);
    }
}

I know that the issue is because string[] is not int but how can I fix that? That’s how I will fill every row of my list.

Edit: LogCat added:

05-03 17:09:46.290: E/AndroidRuntime(271):  at com.zvzej.jlgproapps.mexicoguia.myMain$eHolder.populateFrom(myMain.java:468)
05-03 17:09:46.290: E/AndroidRuntime(271):  at com.zvzej.jlgproapps.mexicoguia.myMain$eAdapter.getView(myMain.java:456)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.AbsListView.obtainView(AbsListView.java:1315)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.ListView.onMeasure(ListView.java:1109)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.View.measure(View.java:8171)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.RelativeLayout.measureChild(RelativeLayout.java:563)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:378)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.View.measure(View.java:8171)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.View.measure(View.java:8171)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.View.measure(View.java:8171)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.View.measure(View.java:8171)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.View.measure(View.java:8171)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.os.Looper.loop(Looper.java:123)
05-03 17:09:46.290: E/AndroidRuntime(271):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-03 17:09:46.290: E/AndroidRuntime(271):  at java.lang.reflect.Method.invokeNative(Native Method)
05-03 17:09:46.290: E/AndroidRuntime(271):  at java.lang.reflect.Method.invoke(Method.java:521)
05-03 17:09:46.290: E/AndroidRuntime(271):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-03 17:09:46.290: E/AndroidRuntime(271):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-03 17:09:46.290: E/AndroidRuntime(271):  at dalvik.system.NativeStart.main(Native Method)
  • 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-03T04:01:30+00:00Added an answer on June 3, 2026 at 4:01 am

    Have you tried:

    holder.populateFrom(Estados[position]);
    

    Addition

    Is this:

        esname = (TextView) row.findViewById(R.id.ename);
    

    Supposed to be:

        esname = (TextView) row.findViewById(R.id.esname);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone maybe tell me what i'm doing wrong? I'm betting im missing one
VISUAL C++ Question Hi, I have array of 3 elements and I want to
Have an array of chars like char members[255]. How can I empty it completely
I have an array of bytes (any length), and I want to encode this
I have an array that I'm appending to in a loop: array_push($obj->{$type.'listings'}, $listing); The
I have a TV named Kategorie and I want a list of all resources
I have been struggling with this for long. I read many resources but still
I have a load of hierarchal static configuration data that I want to read,
I have an application that generates an array of statistics based on a greyhounds
I have ListPreference that has 4 choices/options, I want to check for the selected

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.