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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:24:42+00:00 2026-05-28T05:24:42+00:00

So I have this class here: package phil.droid.game; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle;

  • 0

So I have this class here:

package phil.droid.game;


import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class GameList extends GamesTrialActivity
{

private ListView lv1;
protected String Game_names[]={"God of War","FOS RO DAH", "dhwaud"};
private String Game_pics[]={"God of War","God of War II"};
private int pos;
public void onCreate(Bundle savedInstanceState) 
{   
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gamelist);
    lv1=(ListView)findViewById(R.id.thegamelist);

   lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , Game_names));
   lv1.setOnItemClickListener(new OnItemClickListener() 
    {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
            {


                    pos = position;       
                Intent i = new Intent(GameList.this, game_viewer.class);
                startActivity(i);

            }
    });


}               
}

And then this VclassV extends the one ^above^

package phil.droid.game;

import android.os.Bundle;
import android.widget.TextView;
public class game_viewer extends GameList
{


    public void onCreate(Bundle savedInstanceState)
    {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.game_template);

            TextView game_title = (TextView)findViewById(R.id.GameTitle);
            game_title.setText("" + pos);
    }
}

The problem is at the moment that the last bit recognizes “pos” as “0” no matter what option I click on. Can someone suggest a way to make it so pos is recognized as the number element that’s clicked on in the previous class?

  • 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-28T05:24:43+00:00Added an answer on May 28, 2026 at 5:24 am

    What you’re trying to do can’t work: The newly launched activity will not share the same storage as the parent, even if they inherit. The only way it would be possible is if the value was static, but that’s not a good idea either.

    What you should do instead is to send the data as part of the intent before starting the activity, e.g.:

    intent.putExtra("pos", position);
    

    and then you can pull it out in the new activity with

    getIntent().getIntExtra("pos", -1); // -1 is used as default value
    

    Also, game_viewer should most likely be a separate activity, rather than inherit from GameList.

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

Sidebar

Related Questions

I have this code: package graphics { import flash.display.Sprite; import flash.events.*; public class Ball
I have this class ('Scheduler.as'): package { import flash.events.TimerEvent; import flash.utils.Timer; public class Scheduler
I have this class called SiteAsyncDownload.cs Here's the code: public class SiteAsyncDownloader { WebClient
Okay so I have this mode: class Posts(db.Model): rand1 = db.FloatProperty() #other models here
Here's the deal. I have a big class hierarchy and I have this one
I have this class package somePackage { public class SomeClass { public static const
i have this little class to make a multiple replace on a string: import
I have this model: public class Package { public string CustomerName { get; set;
I have a class in a package that I cannot alter. This class does
hi i have this really basic class here .. and i want to use

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.