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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:45:34+00:00 2026-05-21T14:45:34+00:00

Need some assistance, please. I am attempting to pass data from one activity to

  • 0

Need some assistance, please. I am attempting to pass data from one activity to another, and I know, there are tons of examples of this, and I have achieved the basics of loading a ListActivity from the strings.xml and pulling the button .text from the button and passing it along to the next activity. However, what I need is to apply attribute data to the xml list and pass THAT instead; so on the receiving activity I can receive an id that correlates to what was clicked so I can pull the relevant data I want to display from the strings.xml. OR just pass the data I want to display through putExtra. See code below:

— Sending Activity —

onListItemClick(ListView l, View v, int position, long id) {
 . . .
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
 . . .
Intent myIntent = new Intent(v.getContext(), Activity1.class);
String s = keyword;
Intent i = new Intent(activity.this, activity.class);
myIntent.putExtra("com.activity.Key", s);
startActivityForResult(myIntent, 0);
 . . .

— Receiving Activity —

onCreate(Bundle savedInstanceState) {
 . . .
String data = null;
Bundle extras = getIntent().getExtras();
if (extras != null) {
    data = extras.getString("com.activity.Key");
} else {
    data = "Extras Was Null";
}
 . . .

As you can see I am getting the text data from the button, which doesn’t really help me get to the content that correlates to that button. I feel like I need to pass the Node’s ID instead, but cannot figure it out. I feel as though I am right there, but am missing something.

By request, here is the XML I am inflating. I added the second array (content) so I may match the content to what was pressed in the ListActivity (root_menu); it is a work in progress…

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, activity!</string>
<string name="app_name">Activity Tutorial</string>
<string-array name="root_menu">
    <item id="o1">Item 1</item>
    <item id="o2">Item 2</item>
    <item id="o3">Item 3</item>
    <item id="o4">Item 4</item>
</string-array>
<string-array name="content">
    <item>Content for Item 1.</item>
    <item>Content for Item 2.</item>
    <item>Content for Item 3.</item>
    <item>Content for Item 4.</item>
</string-array>
</resources>
  • 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-21T14:45:35+00:00Added an answer on May 21, 2026 at 2:45 pm

    Could you post the corresponding XML? By “button” you mean list item, correct? It sounds like you are trying to store data in the XML item nodes as attributes, correct?

    Unfortunately I don’t think that is supported by Android – the resource XML files are precompiled and cannot be modified from there, and I don’t believe you can arbitrarily define new attributes to be retrieved either.

    (However, what you can do if you only need to read (and not write to) resource XML is define new types of nodes, and retrieve their values accordingly (probably including attribute values, but I’ve yet to try it))…

    However, this may not help you if all you’re trying to do is retrieve the value of a list selection, which is usually done by just maintaining an array of values that match the list.

    Let me know if I’m totally missing the point of your question.

    Edit: Looks like you’re just trying to find out which list item was clicked, as opposed to the content of that item. Use the “position” parameter of onListItemClicked to get the index.

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

Sidebar

Related Questions

I need some help from the shell-script gurus out there. I have a .txt
I've been given a problem that I need some assistance from the SO community
I have looked all over the net and need some assistance. Is there a
I need some basic CMS functionality with rich text editing. On stack overflow there
I need some help regarding algorithm for randomness. So Problem is. There are 50
PHP has never been my strong suit so I need some assistance getting the
I'm predominately a Java guy, which is why I need some assistance on what
I need assistance in accessing a nested array located my JSON Data Set. Here
Need some help or some advice with entity framework v4. As you already know,
Need some assistance with my Visual Studio projects and in particular with release process.

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.