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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:55:46+00:00 2026-05-24T17:55:46+00:00

I have really no idea why it doesn’t show text. If you look at

  • 0

I have really no idea why it doesn’t show text.

If you look at the class 2, then then I save nimi2 as shared preference. But it doesn’t show up in class 1. I made small test. I replaces name 2 with “plaplapla” (note the “”) and it showed up as plaplapla. But I want it to show up whatever person types as his name. I am new to java. I am yet again really out of ideas :(. Can someone help?

package viimane.voimalus;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.TextView;

public class MainStuff extends Activity {
    TextView tere;
    String nimi;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        tere = (TextView) findViewById(R.id.tvTere);
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        boolean nimiOlemas = preferences.getBoolean("nimionolemas", false);
        nimi = preferences.getString("nimi2", "");
        if (nimiOlemas == false){
             startActivityForResult(new Intent(this, nimekysija.class), 0);
             finish();
        }
        if (nimiOlemas == true){
            tere.setText("Tere " + nimi);
        }

    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // get data from shared preference here
        super.onActivityResult(requestCode, resultCode, data);
    }
}

package viimane.voimalus;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class nimekysija extends Activity {

    EditText nimi;
    SharedPreferences preferences;
    String nimi2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nimekysija);
        preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        nimi = (EditText) findViewById(R.id.etNimekysija);
        nimi2 = nimi.getText().toString();
        Button kysOk = (Button) findViewById(R.id.bNimekysija);
        kysOk.setOnClickListener(new View.OnClickListener() {      

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                SharedPreferences.Editor editor = preferences.edit();
                editor.putString("nimi2", nimi2); // nime kirjutamine
                editor.putBoolean("nimionolemas", true); // nimi on kirjutatud!
                editor.commit();
                startActivity(new Intent("viimane.voimalus.MAINSTUFF"));
                finish();

            }
        });
    }

}

and XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView android:text="" android:id="@+id/tvTere" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TextView android:text="Palun sisestage oma nimi!" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"></TextView>
    <EditText android:id="@+id/etNimekysija" android:layout_height="wrap_content" android:layout_width="fill_parent">
    </EditText>
    <Button android:text="OK!" android:id="@+id/bNimekysija" android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="onAddClick"></Button>

</LinearLayout>
  • 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-24T17:55:46+00:00Added an answer on May 24, 2026 at 5:55 pm

    I found solution for my answer. I removed onActivityResult and in 2nd class just made small move. Moved nimi2 = nimi.getText().toString(); into button onClick :).

    Thank you ntc for help :). I couldn’t wait for your respond so I just searched googled a lot and so on :P.

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

Sidebar

Related Questions

This probably sounds really stupid but I have noo idea how to implement jquery's
I have really no idea why I'm asking this as this a really completely
Sorry about the strange title. I really have no idea how to express it
Since I'm pretty new this question'll certainly sound stupid but I have no idea
I really have little idea how ACL do work. I know it's pretty cool
I have really basic question. How can I get form id by input element
Im new to iPhone development and I have really taken this to me. I
I've got a program where a lot of classes have really complicated configuration requirements.
We’ve found that the unit tests we’ve written for our C#/C++ code have really
What should i use to code Classic ASP under Linux. I have really tried

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.