delevlop problem with my app (help me)


  1. JOKERJOKER

    JOKERJOKER New Member



    //// i have my problem on the last part, i need when the clickcounter will be 0 then show me a alertdialog message.
    I dont know where i have the mistake so please try to help me! thanks!////





    ackage
    eat.all.you;

    import


    eat.all.you.R;

    import


    android.app.Activity;
    import


    android.app.AlertDialog;
    import


    android.content.DialogInterface;
    import


    android.os.Bundle;
    import


    android.view.View;
    import


    android.view.View.OnClickListener;
    import


    android.widget.Button;
    import


    android.widget.EditText;
    import


    android.widget.ProgressBar;
    import


    android.widget.RadioButton;



    public


    class MainActivity extends Activity {

    // References to UI views
    EditText


    txtCount;
    RadioButton radioUp;
    RadioButton radioDown;
    Button btnCount;

    intcount = 50; // Initial count
    ProgressBar


    myProgressBar; intmyProgress = 50;






    /** Called when the activity is first created. */
    @Override
    publicvoid onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); // Set content view to XML layout


    myProgressBar=(ProgressBar)findViewById(R.id.progressBar1);

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("I'm hungry...");
    alertDialog.setMessage("Are you ready??");
    alertDialog.setButton2("GO!", new DialogInterface.OnClickListener() {
    publicvoid onClick(DialogInterface dialog, int which) {

    // here you can add functions

    }
    });
    alertDialog.setIcon(R.drawable.fat);
    alertDialog.show();




    // Retrieve references to UI views by their id in XML layout


    txtCount = (EditText)findViewById(R.id.txtCountId);
    txtCount.setText(String.valueOf(count)); // Set initial value


    btnCount = (Button)findViewById(R.id.btnCountId);

    // Process the button on-click event

    btnCount.setOnClickListener(new OnClickListener() {
    @Override
    publicvoid onClick(View arg0) {

    {

    // Counting up
    count--;
    myProgress--;
    myProgressBar.setProgress(myProgress);

    }
    txtCount.setText(String.valueOf(count));
    }








    publicvoid onClicklistener(View v) {


    if(count == 0)

    {
    AlertDialog.Builder message = new AlertDialog.Builder(MainActivity.this);
    message.setTitle("wooo");
    message.setMessage("woohoo");
    message.show();
    }


    };
    });





    };
    }




    ///thanks 4 help////


    Advertisement

Share This Page