Go Back   Android Forums > Android Development > Application Development > App Inventor

New Forums: Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old July 16th, 2011, 06:15 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jul 2011
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Question delevlop problem with my app (help me)



//// 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////


Advertisements
JOKERJOKER is offline  
Reply With Quote
sponsored links
Reply
Tags
alertdialog, count, develop


Go Back   Android Forums > Android Development > Application Development > App Inventor
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:23 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.