私はAndroidの初心者で、Intent関数を介して変数を受信しようとしています。変数の値に応じて、コンテンツビューが表示されるはずです。
Bundle parametros = getIntent().getExtras();
String type = parametros.getString("tipo");
int accao = parametros.getInt("accao");
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (type=="medicamentos") {
Button voltar = (Button) findViewById(R.id.button1);
voltar.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent medIntent = new Intent(view.getContext(), Listar.class);
startActivityForResult(medIntent, 0);
}
});
if (accao==1)
setContentView(R.layout.adicionar_medicamentos);
if (accao==2)
setContentView(R.layout.editar_medicamentos);
}
}
私が間違っているのは何ですか?ありがとう