My screenshot and code follows.the app crashes When i input all the info and press save details button !
Can anyone help to solve it ?
And one more question: i need this dialog box later to insert it in each of my list view. Is that difficult ?
when i write all the info i want and press save details the app crashes! Can anyone help?
Here is my code too: `
package com.example.user.dialogbox;
import android.app.Activity;
import android.app.Dialog;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity{
Button btn_details;
TextView textDialog1;
TextView textDialog2;
TextView textDialog3;
TextView textDialog4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textDialog1 = (TextView)findViewById(R.id.text1 );
textDialog2 = (TextView)findViewById(R.id.text2);
textDialog3 = (TextView)findViewById(R.id.text3);
textDialog4 = (TextView)findViewById(R.id.text4);
btn_details = (Button)findViewById(R.id.button_details);
btn_details.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showCustomDialog(textDialog1);
showCustomDialog(textDialog2);
showCustomDialog(textDialog3);
showCustomDialog(textDialog4);
}
});
}
protected void showCustomDialog(final TextView _textDialog) {
final Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.customdialog);
final EditText edit1 = (EditText)dialog.findViewById(R.id.edit1);
final EditText edit2 = (EditText)dialog.findViewById(R.id.edit2);
final EditText edit3 = (EditText)dialog.findViewById(R.id.edit3);
final EditText edit4 = (EditText)dialog.findViewById(R.id.edit4);
final TextView text1 = (TextView)dialog.findViewById(R.id.text1);
final TextView text2 = (TextView)dialog.findViewById(R.id.text2);
final TextView text3 = (TextView)dialog.findViewById(R.id.text3);
final TextView text4 = (TextView)dialog.findViewById(R.id.text4);
Button button = (Button)dialog.findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
_textDialog.setText(edit1.getText().toString());
_textDialog.setText(edit2.getText().toString());
_textDialog.setText(edit3.getText().toString());
_textDialog.setText(edit4.getText().toString());
_textDialog.setText(text1.getText().toString());
_textDialog.setText(text2.getText().toString());
_textDialog.setText(text3.getText().toString());
_textDialog.setText(text4.getText().toString());
dialog.dismiss();
}
});
dialog.show();
}
}