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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:05:05+00:00 2026-06-02T17:05:05+00:00

Sorry for the formating errors – How do you use position once you have

  • 0

Sorry for the formating errors – How do you use position once you have it (or another variable for that matter) to activate a file or other task? For example I want to use position 1 to open screen1.java and position 2 to open screen2.java. I could use if/else statements but can I do it in one line rather than many? If I had 100 different screens then an if then statement would be silly. Here is what I have as an (incorrect) example. Can you help me correct it?

public void onItemClick(AdapterView<?> parent, View v,
int position, long id){
//opens relevant game window
Intent intent = new Intent(context, "game"+(position)+"mainscreen"+".class");
startActivity(intent);
} 
});
}

TO SUMMARIZE:-
instead of using game1mainscreen.class I want to use something like “game”+(position)+”mainscreen”+”.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-06-02T17:05:09+00:00Added an answer on June 2, 2026 at 5:05 pm

    You can define intent filter for your activities in AndroidManifest.xml file as follows

    <activity
      android:name=".Game1MainScreen"
      android:label="@string/app_name"
        <intent-filter>
          <action android:name="com.mygame.game1mainscreen" />
          <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    

    and after that use following code to start your game activity

    Intent intent = new Intent("com.mygame.game"+(position)+"mainscreen");
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a resultes set that looks like the following in a table var(sorry
Sorry if this is a dup; I haven't found any questions that pose quite
Sorry for a pretty specific question. I have a table (see bottom), and when
Sorry if this is a stupid question... I've developed an application that creates absolute
Sorry if the title doesn't make sense. Basically I have a series of strings
I have two tables, splits and dividends that describe events in the stock market.
In my specific case I have (function(){ and I want to replace that with
So I have a base table that looks something like this. SELECT [BILL_MONTH] ,[BILL_YEAR]
I have a static class that creates several worker threads in its constructor. If
Sorry for a long question and not a very descriptive title, but my problem

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.