Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old December 22nd, 2012, 08:42 PM   #1 (permalink)
Member
Thread Author (OP)
 
Join Date: Jul 2010
Posts: 109
 
Device(s):
Carrier: Not Provided

Thanks: 17
Thanked 2 Times in 1 Post
Default Help learning how custom Alert Boxes work

So I'm trying to figure out how to make a custom dialog pop up on a function call, yet my app crashes when I try to pop it up on the app.

[HIGH] public void eventpopUpDialog(BluetoothAdapter bluetooth){
//Sets up the layout for the popup box
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITL E);
dialog.setContentView(R.layout.bluetooth_popup_sta tus);

//Make the variables for each UI element on the pop up box
TextView output = (TextView) findViewById(R.id.popupDialogTV);
final Button close = (Button) findViewById(R.id.closePopUp);

//testing to see what is crashing
output.setText("test");

//The Event to close the dialog
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});

dialog.show();
}
[/HIGH]

This is the code in question, I'm at a lost for why it's not working >_>.

Arehexes is offline  
Reply With Quote
sponsored links
Old December 24th, 2012, 10:24 PM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

Can you please post a copy of the logcat output?
__________________
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote
Old January 7th, 2013, 04:23 PM   #3 (permalink)
Member
Thread Author (OP)
 
Join Date: Jul 2010
Posts: 109
 
Device(s):
Carrier: Not Provided

Thanks: 17
Thanked 2 Times in 1 Post
Default

Quote:
Originally Posted by jonbonazza View Post
Can you please post a copy of the logcat output?
Wow I'm sorry for this late response I was busy the last two weeks, here is the logcat file from debugging the app.




Arehexes is offline  
Reply With Quote
Old January 7th, 2013, 11:00 PM   #4 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

Whats on line 122 of MainActivity.java?
jonbonazza is offline  
Reply With Quote
Old January 8th, 2013, 05:01 PM   #5 (permalink)
Member
Thread Author (OP)
 
Join Date: Jul 2010
Posts: 109
 
Device(s):
Carrier: Not Provided

Thanks: 17
Thanked 2 Times in 1 Post
Default

Quote:
Originally Posted by jonbonazza View Post
Whats on line 122 of MainActivity.java?
Again I'm super sorry for the late response last time.

This is what was in line 122

PHP Code:
output.setText("test"); 
I'm guessing it's not working cause it's trying to talk to a object that is null. But I'm setting the object on line 118

PHP Code:
TextView output = (TextViewfindViewById(R.id.popupDialogTV); 
Arehexes is offline  
Reply With Quote
Old January 9th, 2013, 04:40 AM   #6 (permalink)
Junior Member
 
Join Date: May 2012
Posts: 27
 
Device(s): Nexus 7 (Android 4.2.1), Samsung Galaxy Mini (Android 2.3.6)
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

I am not sure if it helps but you could try dialog.findViewById

[HIGH]TextView output = (TextView) dialog.findViewById(R.id.popupDialogTV); [/HIGH]
myrecek is offline  
Reply With Quote
The Following User Says Thank You to myrecek For This Useful Post:
Arehexes (January 9th, 2013)
Old January 9th, 2013, 11:14 AM   #7 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

Quote:
Originally Posted by myrecek View Post
I am not sure if it helps but you could try dialog.findViewById

[HIGH]TextView output = (TextView) dialog.findViewById(R.id.popupDialogTV); [/HIGH]
This is what I was going to say. This should fix your problem.
jonbonazza is offline  
Reply With Quote
Old January 9th, 2013, 04:04 PM   #8 (permalink)
Member
Thread Author (OP)
 
Join Date: Jul 2010
Posts: 109
 
Device(s):
Carrier: Not Provided

Thanks: 17
Thanked 2 Times in 1 Post
Default

Thanks this worked, wonder why it was so hard to find the answer too >_>.
Arehexes is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
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 02:08 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.