Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Help with Dialog - ANDROID

Options
  • 04-04-2014 1:35pm
    #1
    Registered Users Posts: 72 ✭✭


    Hi Ya - Any Chance someone can assist me with my following query please as i have searched google and just cannot seem to find what i am looking for - thanks...

    So on Screen 2 of my app - there is a listview (which will be populated by the Database) and a 'ADD NEW' button which when clicked brings the user to screen 3 where they will enter the details of the Site - name, address etc etc -

    What i need is when the user clicks the 'ADD NEW' button, i want a Dialog box to pop up where it prompts the user to Enter the Site Name (Which after clicking OK or PROCEED will then bring them to Screen 3 and put this Site Name in the Site Name field of screen 3).

    I also need either on same Dialog or another Dialogue after Site name has been entered a short Message saying something like - "Are you Sure you wish to Proceed with the Audit for this Site?" and then 2 buttons - 'OK' and 'CANCEL'

    What i have tried but has not worked is created a new layout(xml) and put a edittext, textview and 2 buttons and then within my java class for screen 2, i have a method already for the 'ADD NEW' button - i tried putting the following code in..

    [code]
    public void addBuilding(View v){

    try{
    if(v.getId()==R.id.addNewButton){
    new AlertDialog.Builder(this)
    .setTitle("CONFIRM YOUR REQUEST")
    .setMessage("Are you sure you wish to Proceed?")
    .setPositiveButton("OK", new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int id) {
    finish();

    }
    }).setNegativeButton("CANCEL", null).show();
    [code]

    But it doesnt work - Can you guide me to how to do this please??

    Thanks in advance


Comments

  • Registered Users Posts: 7,863 ✭✭✭The_B_Man


    So is that the code for when you click the "Add New" button?
    What problem are you having? That the edit text isnt showing?
    If so, you need to tell it to use your xml. In other words, beside .setTitle etc, try .setContentView(R.id.customView);


  • Registered Users Posts: 72 ✭✭shanard


    Will try thay B_Man thanks.... it doesnt seem to be even seeing the dialog class file where i set the content view here in onCreate().....

    I have an xml where i have my editText and 2 buttons and the java file for this activity is where i put my code..... do i need to do an intent or anything like that within my addBuilding() as i have been trying so many things since this morning but keeps crashing....


  • Registered Users Posts: 7,863 ✭✭✭The_B_Man


    You have a custom class that extends Dialog?
    If so, you shouldnt be using "AlertDialog.builder()" as far as I know.
    you should be using "MyClass.builder()".


  • Registered Users Posts: 72 ✭✭shanard


    The_B_Man wrote: »
    You have a custom class that extends Dialog?
    If so, you shouldnt be using "AlertDialog.builder()" as far as I know.
    you should be using "MyClass.builder()".

    Grand - i will try that in the morning as heading out now..... thanks again. Hope it works....


Advertisement