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

  • Home
  • SEARCH
  • 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 8105147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:05:23+00:00 2026-06-06T00:05:23+00:00

I am self- learner to android, Assume an android program is going to display

  • 0

I am self- learner to android,

Assume an android program is going to display some result on a textview.can any one tell me how to show that answer on first tab of the tab host’s on the next screen.How to achieve this?

As per my knowledge i googled and found “Shared preference” concept will be helpful to this problem. Was i right?

And i found some samples but they are not making me clear,can any one give me some examples with screen images.

Thanks for your precious time!.

  • 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-06T00:05:24+00:00Added an answer on June 6, 2026 at 12:05 am

    here is a small sample in this whatever you enter in first tab it is shown on second tab:

    Main class

    public class CheckkActivity extends TabActivity {
     /** Called when the activity is first created. */
      @Override      
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Resources res = getResources();                 
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab
    
    
        intent = new Intent().setClass(this, NewActivity.class);
    
    
        spec = tabHost.newTabSpec("first").setIndicator("First")
                      .setContent(intent);
        tabHost.addTab(spec);
    
    
        intent = new Intent().setClass(this, SecondActivity.class);
        spec = tabHost.newTabSpec("second").setIndicator("Second")
                      .setContent(intent);
        tabHost.addTab(spec);
    
    
    
        tabHost.setCurrentTab(0);
    
    }
    }
    

    NewActivity

         public class NewActivity extends Activity{
        EditText get;
        Button save;
         SharedPreferences sharedPreferences;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.next);
            get=(EditText)findViewById(R.id.next);
            save=(Button)findViewById(R.id.button1);
    
    
              save.setOnClickListener(new OnClickListener() {
    
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    if(get.getText().toString().equalsIgnoreCase("")){
                        Toast.makeText(getApplicationContext(), "enter something", Toast.LENGTH_SHORT).show();
                    }else{
                    sharedPreferences=PreferenceManager.getDefaultSharedPreferences(NewActivity.this);
                       Editor editor1 = sharedPreferences.edit();
                       editor1.remove("answer");
                       editor1.commit();
                     sharedPreferences=PreferenceManager.getDefaultSharedPreferences(NewActivity.this);
                      Editor editor = sharedPreferences.edit();
                      Log.i("set value",""+get.getText().toString());
                      editor.putString("answer",get.getText().toString());
                      editor.commit();}
                }
            });
    
        }
    
       }
    

    SecondActivity

          public class SecondActivity extends Activity{
    TextView set;
    SharedPreferences sharedPreferences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
        set=(TextView)findViewById(R.id.second);
    
    }
    
         @Override
         protected void onResume() {
    // TODO Auto-generated method stub
    sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(SecondActivity.this);
    String answer= sharedPreferences.getString("answer", "");
    Log.v("get value",""+answer);
    if(answer.equalsIgnoreCase(null)){
        set.setText("nothing to display");
    }else{
    set.setText(answer);
    }
    super.onResume();
         }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am self learner to android. Right now i have five pages in an
I am self-leaner to android and java.Is there any session variables available in android
I just recently learned about self calling anonymous functions. Some snippets of code that
I just learned yesterday from this site that I can: class Seq(object): def __init__(self,
I'm trying to self-study C using C Primer Plus from Stephen Prata and one
Is there anything I can use to have PHP execute in a self contained
i am self_learner to android. I have two screens.The first screen contains one edittext
i am self-leaner to android.Right now i am consuming web service in android eclipse
[[self enclosingScrollView] setHorizontalLineScroll:0]; the above api doesnt works. Help Appreciated...
[[self mainFrame] loadHTMLString:@<html><body><link href='main.css' rel='stylesheet' type='text/css' /></body></html> baseURL:nil]; I am trying to load a

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.