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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:17:22+00:00 2026-05-26T18:17:22+00:00

So as of current I am making an Android application with multiple layout files

  • 0

So as of current I am making an Android application with multiple layout files that swap on a button click. Currently I am having an issue. I have a user click a button that opens an AlertDialog with multiple radio buttons, they select one then hit Ok. This sets a global CharSequence Then once they are sure that is what they want they will hit Done to go to the next screen. Here is the code for the Done button.

<Button android:layout_height="wrap_content" android:id="@+id/doneEventButton"       android:text="@string/doneEventButton" android:layout_width="138dp" android:onClick="nextEvent"></Button>

And here is the code for nextEvent.

public void nextEvent()
{
    if (eventVarString == "Send A Text")
    {
        setContentView(R.layout.send_text);
    }
    else if (eventVarString == "Make A Call")
    {
        setContentView(R.layout.make_call);
    }
    else if (eventVarString == "Open An App")
    {
        setContentView(R.layout.open_app);
    }
    else if (eventVarString == "Send An Email")
    {
        setContentView(R.layout.send_email);
    }
    else if (eventVarString == "Go To A Website")
    {
        setContentView(R.layout.go_to_a_website);
    }
}

Here is the code that pops up the AlertDialog and sets the global variable.

public void typeOfEvent(View v)
{
        final CharSequence[] items = {"Send A Text", "Make A Call", "Open An App", "Send An Email", "Go To A Website"};

        AlertDialog.Builder builder = new AlertDialog.Builder(SchedulerActivity.this);
        builder.setTitle("Choose An Event");
        builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                eventVarString = items[item];
         Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
            }
        });

        builder.setPositiveButton("Yes",
         new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
           TextView addEventVarText = (TextView) findViewById(R.id.eventChosen);
           addEventVarText.setText(eventVarString);
           Toast.makeText(SchedulerActivity.this, "Success", Toast.LENGTH_SHORT).show();
          }
         });
        builder.setNegativeButton("No",
         new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
           Toast.makeText(SchedulerActivity.this, "Fail", Toast.LENGTH_SHORT).show();
          }
         });
        AlertDialog alert = builder.create();
        alert.show();
}

And here is the LogCat that is generated from the Force Close when I click the Done button.

Pastebin.com

  • 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-26T18:17:22+00:00Added an answer on May 26, 2026 at 6:17 pm

    Add the parameter View to the event handler.

    public void nextEvent(View view)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new android developer and I am currently making an application to
A website that I'm working on is making extensive use of the HttpContext.Current.Application store
I am making an android application in which I have put 10 images and
I'm creating an android application that gets the current time in a different country/time-zone.
I'm making a small Android application to show current total CPU usage like tab
i am currently making one android application, i moded title bar, so all content
I have a toggle fade effect but when you click the button multiple times
I am making an Android application, but i have a problem. I have no
I have a webserver that hosts data for an application that I'm building on
My current array that I am making produce a different result than I am

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.