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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:37:57+00:00 2026-05-26T23:37:57+00:00

In the first tab I have a listview from where I extract a string,

  • 0

In the first tab I have a listview from where I extract a string, and in the second tab I have a textview. When i click an item in the list, I should go in the second tab and and the string value should be displayed in the textview.

public static String mystring;
protected void onListItemClick (ListView l, View v, int position, long id){
    super.onListItemClick(l, v, position, id);
    mystring = listofHashMap.get(position).get("keyname").toString(); //it's ok here
    Intent intent=new Intent(this, MyActivity.class);
    startActivity(intent);
}

The code above(placed in ListViewActivity) is what i have tried and it works (but MyActivity is not anymore a tabcontent,it is a full-screen standalone activity), having the following code snippet in MyActivity:

tv = (TextView)findViewById(R.id.tvid);
lv = new ListViewActivity();
tv.setText(lv.mystring);

But, as I said I want that MyActivity to be a tabcontent,so I have tried this:

 public MyTabActivity taba = new MyTabActivity();
 protected void onListItemClick (ListView l, View v, int position, long id){
    super.onListItemClick(l, v, position, id);
    mystring = listofHashMap.get(position).get("keyname").toString();
    int i=1;//the tab where I want to go, and MyActivity is its content 
    taba.ChangeTab(i);
}

ChangeTab() is a static method within MyTabActivity(the activity that extends TabActivity ) which simply does setCurrentTab(i) .

So, doing this, MyActivity will always display the name of first clicked item, even I select other items in the list then.I belive that what i have to do is setContent() again for MyActivity or do something with that static String mystring, I have tried many solutions but with no result. I tried to be as accurate I could on what i want to do, please some help on this issue.

  • 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-26T23:37:57+00:00Added an answer on May 26, 2026 at 11:37 pm

    My suggestion would be to use a broadcast. I think that the timing would require a sticky broadcast. Maybe something like this:

    public MyTabActivity taba = new MyTabActivity();
    protected void onListItemClick (ListView l, View v, int position, long id){
        super.onListItemClick(l, v, position, id);
        mystring = listofHashMap.get(position).get("keyname").toString();
    
        // create the intent to send and give it the data
        Intent i = new Intent("updateTextView");
        i.putExtra("textFromList", mystring);
        sendStickyBroadcast(i);
    
        int i=1;//the tab where I want to go, and MyActivity is its content 
        taba.ChangeTab(i);
    }
    

    And then in MyActivity, write something like this:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // your onCreate method
        registerReceiver(updateTextReceiver, new IntentFilter("updateTextView"));
    }
    
    protected void onDestroy() {
        super.onDestroy();
        // your onDestroy method
        unregisterReceiver(updateTextReceiver);
    }
    
    private BroadcastReceiver updateTextReceiver = new BroadcastReceiver() {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            tv = (TextView)findViewById(R.id.tvid);
            String myString = intent.getStringExtra("textFromList");
            if (myString != null) {
                tv.setText(myString);
            }
        }
    
    };
    

    For the sticky broadcast, there’s an additional permission needed in the manifest. I’m not sure but maybe you could just send a regular broadcast if you swapped the order of sending the broadcast and changing the tab.

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

Sidebar

Related Questions

I have a custom control that is derived from ListView . This list view
I have a listview that needs to be multiple choice (i.e each list item
I have a UINavigationController inside a UITabBarController. When a user presses the first tab,
I have a TabActivity with three tabs defined. The first tab is light-weight and
I have a TabView and on its first tab I have a ViewFlipper displaying
I am creating my first tab controller app. I have 2 tabs with 2
I have a tab bar app but the first tab is an image with
Hi I Have 3 tabs in one sceen.. first tab:some edittext fields with some
I have a TabActivity that hosts other three activities. If the first tab is
I have a simple Tab switcher, right now you click on a tab to

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.