У меня 2 класса:Pass метод через/в качестве параметра - Android
TelaCadastroRestaurante (расширяет активность) и Metodos (не распространяется активность).
На моем первом классе у меня есть это: http://i.imgur.com/N0jrjc1.png
На моем втором классе у меня есть это: http://i.imgur.com/PimEoxr.png
Итак, что же я хочу? В моем методе caixaCerteza(), я хочу передать метод mandarNuvem() через/в качестве параметра 3.
общественный класс TelaCadastroRestaurante расширяет активность {
private EditText nomeRestaurante, emailRestaurante, telefoneRestaurante;
private Button buttonProximo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tela_cadastro_restaurante);
incializarComponentes();
acaoBotoes();
}
public void incializarComponentes() {
nomeRestaurante = (EditText) findViewById(R.id.editTextNomeRestauranteTelaCadastroRestaurante);
emailRestaurante = (EditText) findViewById(R.id.editTextEmailRestauranteTelaCadastroRestaurante);
telefoneRestaurante = (EditText) findViewById(R.id.editTextTelefoneRestauranteTelaCadastroRestaurante);
buttonProximo = (Button) findViewById(R.id.buttonProximoTelaCadastroRestaurante);
}
public void acaoBotoes() {
buttonProximo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
pegarValores();
callMandarNuvem();
}
});
}
public void pegarValores(){
final Restaurante rest = new Restaurante();
rest.setNomeRest(nomeRestaurante.getText().toString());
rest.setEmailRest(emailRestaurante.getText().toString());
rest.setTelefoneRest(Integer.parseInt(telefoneRestaurante.getText().toString()));
}
public void callMandarNuvem(){
Metodos.caixaCerteza(TelaCadastroRestaurante.this,
"Você tem certeza que deseja cadastrar o restaurante " + nomeRestaurante.getText().toString() + "?",
Metodos.mandarNuvem(TelaCadastroRestaurante.this));
}
}
общественного класса Metodos {
private static ProgressDialog dialog;
// Metodo que mostra o Aguarde a verificação
public static void taskInProgres(boolean mostrar, Context context) {
if (dialog == null) {
dialog = new ProgressDialog(context);
dialog = ProgressDialog.show(context, "","Espere um momento...", true);
}
if (mostrar) {
dialog.show();
} else {
dialog.dismiss();
}
}
// Metodo que mostra a caixa de certeza
public static void caixaCerteza(final Context context, final String texto, final Metodos metodo) {
AlertDialog.Builder builderaction = new AlertDialog.Builder(context);
builderaction.setTitle("Atenção!");
builderaction.setMessage(texto);
builderaction.setPositiveButton("Sim",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
builderaction.setNegativeButton("Não",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = builderaction.create();
alert.setIcon(R.drawable.ic_stop);
alert.show();
}
public static void mandarNuvem(final Context context){
Metodos.taskInProgres(true, context);
Restaurante rest = new Restaurante();
ParseObject restauranteParse = new ParseObject("Restaurante");
restauranteParse.put("nomeRestaurante", rest.getNomeRest());
restauranteParse.put("emailRestaurante", rest.getEmailRest());
restauranteParse.put("telefoneRestaurante", rest.getTelefoneRest());
restauranteParse.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Toast.makeText(context,"Salvo com sucesso!", Toast.LENGTH_SHORT).show();
Metodos.taskInProgres(false, context);
} else {
Toast.makeText(context, e.getMessage(),Toast.LENGTH_SHORT).show();
}
}
});
}
Не размещайте ваш код или другой текст в качестве изображения, копируйте и вставьте в свой вопрос. – gvlasov
@Suseika, Хорошо, извините – lurdes