Android app crashing (shared preferences) - android

I am building an android game that uses saves. That means that a user can open up to 5 unique saves on the game. to create a new save, im using SharedPreferences to let the user enter a save name and store it in my SharedPreferences folder, and then redirect the user to the main game Activity with an Intent Extra that tells the game activity what save to open.
In the design it all sounds ok, but for some reason my application just keeps Force closing.
I dont have any code errors inside eclipse, and even LogCat shows no error. I dont know what
is going on...
Here is my code:
package ent.com;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
public class Saves extends ListActivity{
String saves[] = { "Empty save", "Empty save", "Empty save", "Empty save", "Empty save"};
public static String filename = "SharedData";
SharedPreferences someData;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
someData = getSharedPreferences(filename, 0);
String save1 = someData.getString("0", "Empty save");
String save2 = someData.getString("1", "Empty save");
String save3 = someData.getString("2", "Empty save");
String save4 = someData.getString("3", "Empty save");
String save5 = someData.getString("4", "Empty save");
saves[0] = save1;
saves[1] = save2;
saves[2] = save3;
saves[3] = save4;
saves[4] = save5;
setListAdapter(new ArrayAdapter<String>(Saves.this, android.R.layout.simple_list_item_1, saves));
}
#Override
protected void onListItemClick(ListView l, View v,int position, long id) {
final String clicked = saves[position];
final String pos = getString(position);
super.onListItemClick(l, v, position, id);
if(clicked=="Empty save"){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Input name");
alert.setMessage("Give your team a name:");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
SharedPreferences.Editor editor = someData.edit();
editor.putString(pos, value);
editor.commit();
try{
Class Joe = Class.forName("ent.com.TestActivity");
Intent Joey = new Intent(Saves.this, Joe);
Joey.putExtra("save", clicked);
startActivity(Joey);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Intent back = new Intent("ent.com.MENU");
startActivity(back);
}
});
alert.show();
}else{
try{
Class ourClass = Class.forName("ent.com.TestActivity");
Intent ourIntent = new Intent(Saves.this, ourClass);
ourIntent.putExtra("save", clicked);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
}
Thanks for any help.

So far all I see that is a big problem is this :
if (clicked=="Empty save")
== is for numbers and reference comparison. you're looking for:
if (clicked.equals("Empty save"))
which will actually compare the strings in question

Related

getText() in EditText is not working

I am currently trying to get a string out of an EditText field.
Here is my Code:
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
public class FirstRunDialog extends DialogFragment {
public static final String DEBUG_TAG = FirstRunDialog.class.getSimpleName();
private static final String PREFS_NAME = "MyPrefsFile";
private LayoutInflater inflater;
private View dialogView;
private EditText input;
private DialogInterface.OnClickListener listener;
private SharedPreferences settings;
private SharedPreferences.Editor editor;
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (activity instanceof DialogInterface.OnClickListener) {
listener = (DialogInterface.OnClickListener) activity;
}
}
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.app_name);
builder.setView(R.layout.first_run_dialog);
builder.setCancelable(false);
builder.setPositiveButton("Key-Testen", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
settings = getActivity().getSharedPreferences(PREFS_NAME, 0);
dialogView = getActivity().getLayoutInflater().inflate(R.layout.first_run_dialog, null);
input = (EditText) dialogView.findViewById(R.id.editText);
editor = settings.edit();
editor.putString("apiKey", input.getText().toString());
editor.commit();
Log.d(DEBUG_TAG, "apiKey Input: " + input.getText().toString());
Log.d(DEBUG_TAG, "apiKey: " + settings.getString("apiKey", ""));
dialog.dismiss();
}
});
builder.setNegativeButton("Key-Erstellen", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//Open Browser, then go to: https://account.arena.net/applications
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://account.arena.net/applications"));
startActivity(browserIntent);
}
});
return builder.create();
}
}
This code is not working! According to the answers how to retrieve text from an EditText I did nothing wrong. The EditText is located in an AlertFragment.
The current output for the Log.d(...) is (and the same goes for the second):
apiKey Input:
Thx in advance.
Do not inflate a new view when the button is pressed.
Try using getDialog():
builder.setPositiveButton("Key-Testen", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
settings = getActivity().getSharedPreferences(PREFS_NAME, 0);
input = (EditText) getDialog().findViewById(R.id.editText);
editor = settings.edit();
editor.putString("apiKey", input.getText().toString());
editor.commit();
Log.d(DEBUG_TAG, "apiKey Input: " + input.getText().toString());
Log.d(DEBUG_TAG, "apiKey: " + settings.getString("apiKey", ""));
dialog.dismiss();
}
});
try this
take out this line from the onclick
input = (EditText) dialogView.findViewById(R.id.editText);
and inflate the view
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.alert_label_editor, null);
builder .setView(dialogView);
EditText input = (EditText) dialogView.findViewById(R.id.editText);
then input.gettext().tostring in the onclick, sorry for my english
and I hope to help

Receiver not asking user to accept file

I am having some difficulty sending files over Bluetooth. After it attempts to send the file, it will list the transfer as having 'failed' with an 'unknown file' error. I have double-checked my file path but am still having this problem. Do you guys see anything that I am missing? The target phone that is supposed to receive the file isn't showing the incoming file notification that asks the user to accept it or not. I believe this is where the failure is. Do you guys know how to pass the 'permission asking' (I guess we can call it that) to the target device?
//some code used from
// http://examples.javacodegeeks.com/android/core/ui/progressdialog/android-progressdialog-example/
// http://developer.android.com/guide/topics/connectivity/bluetooth.html
package com.project.BluetoothTransfer_v1000;
import java.io.File;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
#SuppressLint("DefaultLocale")
public class TransferFragment extends Fragment{
private TextView filePathTextView;
private Button startTransferButton;
private ImageView bluetoothImage;
ProgressDialog transferDialog;
Handler updateBarHandler;
private static final int REQUEST_BLUETOOTH = 1;
private static final int DISCOVER_DURATION = 300;
Context context;
ArrayAdapter mArrayAdapter;
long timeCheckStart = 0;
long timeCheckEnd = 0;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, final Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//set the user interface layout for this activity
setRetainInstance(false);
View v = inflater.inflate(R.layout.activity_bluetooth_transfer, parent, false);
context = this.getActivity();
filePathTextView = (TextView) v.findViewById(R.id.file_path_textView);
startTransferButton = (Button) v.findViewById(R.id.start_transfer_button);
bluetoothImage = (ImageView) v.findViewById(R.id.bluetooth_imageView);
bluetoothImage.setClickable(true);
startTransferButton.setOnClickListener(new View.OnClickListener() {
//start transfer processes
#Override
public void onClick(View v){
//check to make sure the file path text view != null
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
int REQUEST_ENABLE_BT = -1;
//ensure the device being used has bluetooth capability
if (filePathTextView.getText().toString().length() > 4 && btAdapter != null){
//check-enable bluetooth
if (!btAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
//make the device discoverable and check to make sure device isn't already discoverable
if (timeCheckStart == 0 || System.currentTimeMillis() - 60000 > timeCheckStart){
timeCheckStart = System.currentTimeMillis();
Intent discoverableIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 60);
startActivity(discoverableIntent);
}
// /storage/emulated/0/Test.jpg
// /storage/extSdCard/Test.jpg
String filePath = filePathTextView.getText().toString();
Toast.makeText(context, filePath, Toast.LENGTH_LONG);
String fileType = filePath.substring(filePath.length()-3,filePath.length()).toLowerCase();
//handles the sending of different file types
//################## where im having trouble ######################################
switch (fileType){
case "jpg": //allow to fall through to png
case "png": Intent pictureIntent = new Intent(Intent.ACTION_SEND);
pictureIntent.setType("image/*");
pictureIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
startActivity(Intent.createChooser(pictureIntent, "Send Image"));
break;
case "mp3": Intent audioIntent = new Intent(Intent.ACTION_SEND);
audioIntent.setType("audio/*");
audioIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
startActivity(Intent.createChooser(audioIntent, "Send Audio"));
break;
case "txt": Intent textIntent = new Intent(Intent.ACTION_SEND);
textIntent.setType("text/*");
textIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
startActivity(Intent.createChooser(textIntent, "Send Text"));
break;
default: new AlertDialog.Builder(context).setTitle("Alert")
.setMessage("The file type submitted is not supported: ("+fileType+")")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {}
}).show(); break;
}//end fileType switch
}//if text view null (if)
else {
//alert user to input file path
new AlertDialog.Builder(context).setTitle("Error")
.setMessage("Please insert a filename to send and be sure to include the type extension.")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {}
}).show();
}//bt equipped/text view null check (else)
}//end anon class
});
bluetoothImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//display dialog showing program specs and creators
new AlertDialog.Builder(context).setTitle("About")
.setMessage("Created by:"+"\n"+ "Hal, Chris, and Roger")
.setPositiveButton("Awesome!", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
});
return v;
}
}
Maybe this answer can help you:
https://stackoverflow.com/a/19618432/3743093
In short: you can't pass an URI created with
Uri uri = Uri.parse(String);
as in
pictureIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
beacuse it lacks info like TITLE and MIME_TYPE.
That's the reason why file type is unknown (missing) and throws this error.
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, "title");
values.put(Images.Media.MIME_TYPE, "image/*");
Uri uri = getContentResolver().insert(Uri.parse(filename),
values);
pictureIntent.putExtra(Intent.EXTRA_STREAM, uri);
Hope this helps.

Android ListView does not update onResume

I made an Activity for searching people that also shows history of recent research.
If I long click on an item of the history it asks me if I want to delete it. If I press "Yes" it deletes the list item.
So, I write something and click to "Search" button. This brings me in another Activity with results. Here I click on result so it stores the person info and brings me in the person page.
When I come back I don't see the new person in the history.
So I overwritten onResume() but it still not work and now I cannot delete items from the history list.
Here the code:
package com.lpsmt.proffinder;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import com.lpsmt.R;
public class HomeActivity extends Activity
{
protected Db db = null;
protected List<ProfBean> historyProfs = null;
protected ProfListItemAdapter listAdapter = null;
protected ListView listView = null;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.db = new Db(this);
this.setContentView(R.layout.prof_finder_home);
this.historyProfs = this.db.getHistory(-1); // -1 means with no limits
this.listAdapter = new ProfListItemAdapter(HomeActivity.this, R.id.prof_finder_history_list_view, this.historyProfs);
this.listView = (ListView) this.findViewById(R.id.prof_finder_history_list_view);
listView.setAdapter(this.listAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(HomeActivity.this, ProfPageActivity.class);
Bundle bundle = new Bundle();
bundle.putString("profId", HomeActivity.this.historyProfs.get(position).getProfId());
intent.putExtras(bundle);
HomeActivity.this.startActivity(intent);
}
});
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
#Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id)
{
Resources resources = HomeActivity.this.getResources();
String title = resources.getString(R.string.prof_finder_history_delete_title);
String message = resources.getString(R.string.prof_finder_history_delete_message);
AlertDialog.Builder adb=new AlertDialog.Builder(HomeActivity.this);
adb.setTitle(title);
adb.setMessage(message);
final int positionToRemove = position;
String positive = resources.getString(R.string.prof_finder_history_delete_positive);
String negative = resources.getString(R.string.prof_finder_history_delete_negative);
adb.setNegativeButton(negative, null);
adb.setPositiveButton(positive, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
ProfBean prof = HomeActivity.this.historyProfs.get(positionToRemove);
HomeActivity.this.db.deleteProf(prof.getProfId());
HomeActivity.this.historyProfs.remove(positionToRemove);
HomeActivity.this.runOnUiThread(new Runnable() {
public void run() {
HomeActivity.this.listAdapter.notifyDataSetChanged();
}
});
}});
adb.show();
return true;
}
});
}
public void searchProf(View view) throws Exception
{
EditText queryEditText = (EditText) this.findViewById(R.id.prof_finder_search_query);
String query = queryEditText.getText().toString().trim();
queryEditText.setText(query);
if (query.length() < 3) {
String message = this.getResources().getString(R.string.prof_finder_query_too_short);
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
return;
}
Intent intent = new Intent(HomeActivity.this, SearchResultActivity.class);
Bundle bundle = new Bundle();
bundle.putString("query", query);
intent.putExtras(bundle);
this.startActivity(intent);
}
public void onResume()
{
super.onResume();
this.historyProfs = this.db.getHistory(-1);
this.listAdapter.notifyDataSetChanged();
}
}
You haven't set any new data to list view. Thats why your new contact isn't added to the list after notifyDataSetChanged(). You need to add some method into adapter like
setData(List<ProfBean> data)
{
this.currentAdaptersList= data;
}
and then call notifyDataSetChanged(). So the final onResume will be :
public void onResume()
{
super.onResume();
this.historyProfs = this.db.getHistory(-1);
this.listAdapter.setData(this.historyProfs);
this.listAdapter.notifyDataSetChanged();
}
Enjoy.
And using onResume() for this task is bad idea. Is better to use onActivityResult.
notifyDataSetChanged() didn't work for me either. I was able to solve this a little bit differently:
I use OnStart() (in a derived class from Fragment)
I use setNotifyOnChange() of the ArrayAdapter:
ListView listView = (ListView) findViewById(R.id.logListView);
listView.setAdapter(logAdapter);
logAdapter.setNotifyOnChange(true);
I create the adapter once:
logAdapter = new ArrayAdapter(activity, android.R.layout.simple_list_item_1, activity.logMessages);
in onViewCreated().

If password field not filled it should not make link to next activity & show alert. How can i do that?

My code:
package com.example.linkingpage;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class LinkingPage extends Activity {
String tv,tv1;
EditText name,pass;
TextView x,y;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.widget44);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent obj = new Intent(LinkingPage.this,LinkingPage.class);
startActivity(obj);
}
});
x = (TextView) findViewById(R.id.widget46);
y = (TextView) findViewById(R.id.widget47);
name = (EditText)findViewById(R.id.widget41);
pass = (EditText)findViewById(R.id.widget43);
Button button1 = (Button) findViewById(R.id.widget45);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
x.setText(tv);
y.setText(tv1);
tv = name.getText().toString();
if(tv.trim().equals("")) {
// text is empty
showDialog(EMPTY_TEXT_ALERT);
}
tv1 = pass.getText().toString();
if (tv1.trim().equals(""))
{
showDialog(EMPTY_TEXT_ALERT);
}
else
{Intent obj = new Intent(LinkingPage.this,ResourcePage.class);
obj.putExtra("name", name.getText().toString());
obj.putExtra("pass", pass.getText().toString());
startActivity(obj);
}
}
});
}
private final static int EMPTY_TEXT_ALERT = 0;
#Override
public Dialog onCreateDialog(int id) {
switch(id) {
case EMPTY_TEXT_ALERT: {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Message:Field Empty!!!")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
return builder.create();
}
}
return null;
}
}
When both fields are kept empty, and button is clicked alert is generated. Same happens when only name field is filled. But when name field is kept empty and passwor is filled , then though an alert is generated but link to other page is also generated showing my password.How can i prevent this??
Its because your your else that starts your next activity is only applying to your second if statement(the one for the password)
this:
if(tv.trim().equals("")) {
// text is empty
showDialog(EMPTY_TEXT_ALERT);
}
is completely separate from this:
if (tv1.trim().equals(""))
{
showDialog(EMPTY_TEXT_ALERT);
}else
{
Intent obj = new Intent(LinkingPage.this,ResourcePage.class);
obj.putExtra("name",name.getText().toString());
obj.putExtra("pass", pass.getText().toString());
startActivity(obj);
}
In order to make it check both of them you should do something like this:
if(tv.trim().equals("") || tv1.trim().equals(""))
{
showDialog(EMPTY_TEXT_ALERT)
}else{
Intent obj = new Intent(LinkingPage.this,ResourcePage.class);
obj.putExtra("name",name.getText().toString());
obj.putExtra("pass", pass.getText().toString());
startActivity(obj);
}
And again I really cannot stress enough how much easier your could would be to understand if you used descriptive names for your variables instead of things like tv,tv1,button,button1,widget38 etc...
Remove the code from else and put it right there without else there is no requirement of else and after showDialog put return;
and dont post duplicate posts

Help with AlertDialog in Android

The application seems to crash when I try and get the text from the EditText:
package com.example.helloandroid;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.util.Log;
import android.app.Activity;
import android.os.Bundle;
public class MatrixMultiply extends Activity implements OnClickListener {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View newButton = findViewById(R.id.new_button);
newButton.setOnClickListener(this);
View aboutButton = findViewById(R.id.about_button);
aboutButton.setOnClickListener(this);
View exitButton = findViewById(R.id.exit_button);
exitButton.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.about_button:
Intent i = new Intent(this, About.class);
startActivity(i);
break;
case R.id.new_button:
openNewGameDialog();
break;
case R.id.exit_button:
finish();
break;
// More buttons go here (if any) ...
}
}
private static final String TAG = "Matrix";
private void openNewGameDialog() {
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.text, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Matrices");
alert.setMessage("Please enter the size of the matrix");
// Set an EditText view to get user input
alert.setView(textEntryView);
AlertDialog matrixSize = alert.create();
final EditText height1 = (EditText) matrixSize.findViewById(R.id.h1);
final EditText width1 = (EditText) MatrixMultiply.this.findViewById(R.id.w1);
final EditText height2 = (EditText) MatrixMultiply.this.findViewById(R.id.h2);
final EditText width2 = (EditText) MatrixMultiply.this.findViewById(R.id.w2);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String h1 = height1.getText().toString();
String w1 = width1.getText().toString();
String h2 = height2.getText().toString();
String w2 = width2.getText().toString();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
}
private void startGame(int i) { Log.d(TAG, "clicked on " + i); // Start game here...
}
}
it will be crashing due to a thing that you will calling this method from a thread other then UI Main Worker thread.
For debugging purpose try calling this method in the very beginining of app in the main class by main thread.
If it appears then make your threading issue clear in the app.
Use Handler class object to reslove such issues. I will put some more light if you need
The problem is that height1 is not found within the dialog. Really, you shouldn't seearch one within the dialog, because it belongs not to the dialog, but to the activity. Try this:
final EditText height1 = (EditText) YourActivityClassName.this.findViewById(R.id.h1);
It will search for the R.id.h1 within your activity.

Categories

Resources