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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:32:15+00:00 2026-05-29T04:32:15+00:00

I have ListView activity class: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] naziviMolitvi =

  • 0

I have ListView activity class:

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

        String[] naziviMolitvi = getResources().getStringArray(R.array.nazivi_molitvi);
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, naziviMolitvi));

        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
                Intent intent = new Intent(getApplicationContext(), Molitva.class);
                //Bundle bundle = new Bundle();
                //bundle.putInt("pozicija", position);
                //intent.putExtras(bundle);
                startActivity(intent);
//              Toast.makeText(getApplicationContext(),
//                      ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
            }
        });
    }

I have list items stored in strings.xml file in string-array:

<string-array name="nazivi_molitvi">
    <item>Дневне молитве</item>
    <item>Символ вере</item>
    <item>Псалм 50</item>
    <item>Свакодневна молитва</item>
    <item>Молитва Пресветој Богородици у невољи и потиштености</item>
    <item>Поздрав Богородици</item>
    <item>Јутарња молитва</item>
    <item>Вечерња молитва</item>
    <item>Молитва Анђелу Чувару</item>
    <item>Молитва пред Свето Причешће</item>
    <item>Молитва после Светог Причешћа</item>
    <item>Молитва за међусобни мир</item>
    <item>Молитва пре учења</item>
    <item>Молитва после учења</item>
    <item>Молитва пре доручка</item>
    <item>Молитва после доручка</item>
    <item>Молитва пре ручка</item>
    <item>Молитва после ручка</item>
    <item>Молитва пре вечере</item>
    <item>Молитва после вечере</item>
    <item>Десет Божијих Заповести</item>
    <item>Две највеће Христове Заповести</item>
    <item>Химна Светом Сави</item>
    <item>Српска Химна "Боже правде"</item>
</string-array>

Now when user clicks on single item I want to show expanded text for that view. Where to store this text? If I store text in string array then I don’t know how to reference to single item in it.
Maybe for every item to make string with certain name and when user clicks item in list view to have switch statement, like this:

public class Molitva extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.molitva);
        Bundle bundle = this.getIntent().getExtras();
        int pozicija = bundle.getInt("pozicija");
        TextView tv = (TextView) this.findViewById(R.id.textView1); 
        tv.append(" - " + getPrayerText(pozicija));

    }
}

Is that good practice for selecting list item and what you suggest me? How to do this?

  • 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-29T04:32:17+00:00Added an answer on May 29, 2026 at 4:32 am

    I would assume that the list of expanded text is the same size as your list, and the indices are equal and corresponding.

    You can also store the expanded text list on arrays.xml and get hold of them as you did with your non-expanded list – using getResources().getStringArray. You can use the position you passed in the bundle to get the item in your expanded text list.

    String[] expanded_text = getResources().getStringArray(R.array.expanded_text);
    

    // to get the item at position pozicija

    expanded_text[pozicija];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Activity with ListView inside it and in the onCreate method of the
I have an activity class that gets a JSON string by making a query.
I've just started converting my apps to use fragments. I have a ListView activity
I have a problem refreshing a ListView. I call my ListView Activity , I
I have a ListView on my Android Activity. When I scroll it, the background
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have one SubjectTabActivity and i need to show listview on this activity. But
I have an activity which consists of a ListView . The problem is that
I am trying to display ListView . I have created one activity , in
I have following code that displays an Image with letters, public class MainActivity extends

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.