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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:31:30+00:00 2026-05-30T13:31:30+00:00

I am trying to get one string, two integers and one timepicker result from

  • 0

I am trying to get one string, two integers and one timepicker result from a dialog to the activity where this dialog is created. How can I pass this information to this activity?
Below there is my code.

package ilachatirlatici.pack.net;

 import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;
 import android.widget.EditText;

public class HapHatirlatici extends Activity{

Button ekleButton;
boolean eklendiMi;
EditText ilacAdi;
String ilacAdiString;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.haphatirlatici);

    // After creating the activity setting other things for running
    ekleButton = (Button) findViewById(R.id.EkleButton);
    eklendiMi = false;
    ilacAdiString = "";
    ekleButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        // TODO Auto-generated method stub
        ilacAdi = (EditText) findViewById(R.id.KayitAdiEditText);
        View layout = getLayoutInflater().inflate(R.layout.ekle_dialog, null);                               
        AlertDialog.Builder builder = new AlertDialog.Builder(HapHatirlatici.this);
        builder.setPositiveButton(R.string.ekle,new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                eklendiMi = true;
                ilacAdiString =  ilacAdi.getText().toString();
                //ilacAdiString = ilacAdi.getEditableText().toString();
                databaseEkle(eklendiMi, ilacAdiString);
           }
        });
        builder.setNegativeButton(R.string.vazgec, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                eklendiMi = false;
                databaseEkle(eklendiMi, "");
           }
        });
        builder.setView(layout);
        AlertDialog alertDialog = builder.create();
        alertDialog.setTitle("Ilac Ekleme");
        alertDialog.show();


        }
    });
}
public boolean databaseEkle(boolean eklemeVarMi, String ilacAdi)
{
    boolean sonuc = false;
    System.out.println(ilacAdi);
    return sonuc;
}

}

I am trying to get the result in positive button part. I only implemented the string part. Since the other parts will be same. How can I pass this string to the databaseEkle() function?

  • 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-30T13:31:31+00:00Added an answer on May 30, 2026 at 1:31 pm

    You are actually trying to access EditText which is actually inside AlertDialog’s layout R.layout.ekle_dialog. You need to refer to your inflated layout to reference to edittext.

    set your button’s onClick listener like this:

    ekleButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        // TODO Auto-generated method stub
    
        View layout = getLayoutInflater().inflate(R.layout.ekle_dialog, null);
        EditText myEditText = (EditText) layout.findViewById(R.id.KayitAdiEditText);
        AlertDialog.Builder builder = new AlertDialog.Builder(HapHatirlatici.this);
        builder.setPositiveButton(R.string.ekle,new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                eklendiMi = true;
                ilacAdiString =  myEditText.getText().toString();
                //ilacAdiString = ilacAdi.getEditableText().toString();
                databaseEkle(eklendiMi, ilacAdiString);
           }
        });
        builder.setNegativeButton(R.string.vazgec, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                eklendiMi = false;
                databaseEkle(eklendiMi, "");
           }
        });
        builder.setView(layout);
        AlertDialog alertDialog = builder.create();
        alertDialog.setTitle("Ilac Ekleme");
        alertDialog.show();
    
    
        }
    });
    

    in this example i’m using myEditText instead of ilacAdi because you have declared your editText global, which doesn’t need to be in this case

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

Sidebar

Related Questions

I have been trying to get this one section of my UI to immediatly
I'm trying to get content from an RSS2 feed from one of my sites
I am trying to get either the strings checked or the integers from a
I'm trying to compare two millisecond values in Java. One from a calendar, and
I'm trying to get everything before/after a comma from a string var test =
I'm trying to get two divs side by side. The left one will have
two Qs in one day... I'm trying to get the right radio button checked
I'm trying to get a one-to-many relationship working with grails/gorm. I don't understand how
Trying to get MGTwitterEngine app to build. Getting one pesky error. The following ERROR.
I'm having one hell of a time trying to get my databinding to work

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.