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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:39:31+00:00 2026-06-02T16:39:31+00:00

I’m trying to develop a very simple apk. I’m using a textView to show

  • 0

I’m trying to develop a very simple apk.
I’m using a textView to show two team’s name that i enter in a previous activity (brought here with the intent that open this activity).
When i try to use setText to show the names of these teams the apk crash.

This is the class that crash:

    public class MatchPage extends Activity {
private String locali= null;
private String ospiti= null;
private TextView localiTV;
private TextView ospitiTV;
private MatchRugby partita;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.match);
     localiTV =(TextView) findViewById(R.id.localiTV);
     ospitiTV =(TextView) findViewById(R.id.ospitiTV);
    getLocali();
    getOspiti();
    createMatch();



     localiTV.setText("Locali /n"+ partita.teamA.getName());
     ospitiTV.setText("Ospiti /n"+ partita.teamB.getName());




}

/**
 * Prende il nome della squadra locale dall'intent
 * @return
 */
public String getLocali(){
    Intent matchStart = getIntent();
    String locali = matchStart.getStringExtra(NewMatchPage.LOCALI);
    return locali;
}

/**
 * prende il nome della squadra ospite dall'intent
 * @return
 */
public String getOspiti(){
    Intent matchStart = getIntent();
    String ospiti = matchStart.getStringExtra(NewMatchPage.OSPITI);
    return ospiti;
}

public MatchRugby createMatch(){
    TeamRugby teamLocali= new TeamRugby(locali);
    TeamRugby teamOspiti= new TeamRugby(ospiti);
    MatchRugby partita= new MatchRugby(teamLocali, teamOspiti);
    return partita;
}
    }

This is the XML:

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/localiTV"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:textAppearance="?android:attr/textAppearanceLarge" />


<TextView
    android:id="@+id/ospitiTV"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

This is the class that send the intent:

   public class NewMatchPage extends Activity {

public static final String LOCALI = null;
public static final String OSPITI = null;
   private Button startMatch;
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_match);

     startMatch= (Button) findViewById(R.id.startMatch);
        startMatch.setOnClickListener(new View.OnClickListener(){


            public void onClick(View arg0) {
                startMatch();

            }

        });
}

public void startMatch(){
    Intent startMatch= new Intent(this, MatchPage.class);

    //Prendo il testo scritto nella casella locali e la porto nella partita
    EditText locali= (EditText) findViewById(R.id.Locali);
    String locali1 = locali.getText().toString();
    startMatch.putExtra(LOCALI, locali1);
    //Prendo il testo scritto nella casella ospiti e la porto nella partita
    EditText ospiti= (EditText) findViewById(R.id.Ospiti);
    String ospiti1 = ospiti.getText().toString();
    startMatch.putExtra(OSPITI, ospiti1);
    //inizio la partita
    startActivity(startMatch);
}

    }

And finally that’s the logcat log:

    04-24 16:49:08.928: W/dalvikvm(1377): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
    04-24 16:49:08.958: E/AndroidRuntime(1377): FATAL EXCEPTION: main
    04-24 16:49:08.958: E/AndroidRuntime(1377): java.lang.RuntimeException: Unable to start activity    ComponentInfo{com.gmail.david.corsalini.sportscout/com.gmail.david.corsalini.sportscout.MatchPage}: java.lang.NullPointerException
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.os.Handler.dispatchMessage(Handler.java:99)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.os.Looper.loop(Looper.java:137)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.ActivityThread.main(ActivityThread.java:4424)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at java.lang.reflect.Method.invoke(Method.java:511)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at dalvik.system.NativeStart.main(Native Method)
    04-24 16:49:08.958: E/AndroidRuntime(1377): Caused by: java.lang.NullPointerException
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at com.gmail.david.corsalini.sportscout.MatchPage.onCreate(MatchPage.java:25)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.Activity.performCreate(Activity.java:4465)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
    04-24 16:49:08.958: E/AndroidRuntime(1377):     ... 11 more

MatchRugby class

    public class MatchRugby {
public TeamRugby teamA;
public TeamRugby teamB;

/**
 * Costruttore della partita
 */
public MatchRugby(TeamRugby teamA, TeamRugby teamB){
    this.teamA=teamA;
    this.teamB=teamB;
}

/**
 * @return the teamA
 */
public TeamRugby getTeamA() {
    return teamA;
}


/**
 * @param teamA the teamA to set
 */
public void setTeamA(TeamRugby teamA) {
    this.teamA = teamA;
}


/**
 * @return the teamB
 */
public TeamRugby getTeamB() {
    return teamB;
}


/**
 * @param teamB the teamB to set
 */
public void setTeamB(TeamRugby teamB) {
    this.teamB = teamB;
}


public void EndOfMatch(){
    //nothing to do with the problem
    }
}
  • 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-02T16:39:34+00:00Added an answer on June 2, 2026 at 4:39 pm

    Your variable scoping is all off. set up your class like this:

    public class MatchPage extends Activity {
    private String locali= null;
    private String ospiti= null;
    private TextView localiTV;
    private TextView ospitiTV;
    private MatchRugby partita;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     
        setContentView(R.layout.match);
         localiTV =(TextView) findViewById(R.id.localiTV);
         ospitiTV =(TextView) findViewById(R.id.ospitiTV);
        getLocali();
        getOspiti();
        createMatch();
    
         localiTV.setText("Locali /n"+ partita.teamA.getName());
         ospitiTV.setText("Ospiti /n"+ partita.teamB.getName());
    
    }
    
    /**
     * Prende il nome della squadra locale dall'intent
     * @return
     */
    public String getLocali(){
        if (locali == null) {
          Intent matchStart = getIntent();
          locali = matchStart.getStringExtra(NewMatchPage.LOCALI);
        }
        return locali;
    }
    
    /**
     * prende il nome della squadra ospite dall'intent
     * @return
     */
    public String getOspiti(){
        if (ospiti == null) {
          Intent matchStart = getIntent();
          ospiti = matchStart.getStringExtra(NewMatchPage.OSPITI);
        }
        return ospiti;
    }
    
    public MatchRugby createMatch(){
        TeamRugby teamLocali= new TeamRugby(locali);
        TeamRugby teamOspiti= new TeamRugby(ospiti);
        partita = new MatchRugby(teamLocali, teamOspiti);
        return partita
    }
    
      private String locali
      private String ospiti
      private MatchRugby partita
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.