Witam,
Ostatnimi czasy próbuję stworzyć swoją własną aplikację mobilną.
Jak stworzyć warunek, który będzie sprawdzał jakie dane wstawić do TextView.
Wybieram button1 wprowadzane są dane x
Wybieram button2 wprowadzane są dane y
Główna aktywność
click.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent myIntent = new Intent(WyborCPU.this,
NewActivity.class);
startActivity(myIntent);
}
});
click2.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent myIntent = new Intent(WyborCPU.this,
NewActivity2.class); //chcę to wrzucić do Aktywności 1
startActivity(myIntent);
}
});
Listing drugiego (nadrzędnego listingu)
String[] intelNames = {"Procesory Intel® Core™", "Procesory Intel® Pentium ®", "Procesory Intel® Celeron®", "Procesory Intel® Xeon®", "Procesory Intel® Itanium®"};
int[] intelImages = {R.drawable.amd, R.drawable.intel, R.drawable.wyjscie, R.drawable.info, R.drawable.wsparcie};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_activity);
simpleListView=(ListView) findViewById(R.id.simpleListView);
ArrayList<HashMap<String,String>> arrayList=new ArrayList<>();
for (int i=0;i<intelNames.length;i++)
{
HashMap<String,String> hashMap=new HashMap<>();
hashMap.put("name",intelNames[i]);
hashMap.put("image",intelImages[i]+"");
arrayList.add(hashMap);
}
String[] from={"name","image"};
int[] to={R.id.textView,R.id.imageView};
SimpleAdapter simpleAdapter=new SimpleAdapter(this,arrayList,R.layout.intel_proc,from,to);
simpleListView.setAdapter(simpleAdapter);
simpleListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Toast.makeText(getApplicationContext(),intelNames[i],Toast.LENGTH_LONG).show();
}
});
}
Trzeba tutaj zastosować funkcję jeżeli.
Nie mam pojęcia jak ją zadeklarować, dziękuję za wszystkie wskazówki.
Pozdrawiam