I have created a list view and it contains integer values. I have set them inside a textview and now from another layout I need to get those integer values and pass it to another activity! How can I do that? Please help I'm new to android .
private void viewFunction() {
Button messageButton=(Button)findViewById(R.id.btnCreate);
messageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
;
Units units=new Units(dbHandler.getUnitsCount(),String.valueOf(myTry.getText()),String.valueOf(bulbSpn.getSelectedItem()),String.valueOf(fanSpn.getSelectedItem()));
//addUnits(0,myTry.getText().toString(),bulbSpn.getSelectedItem().toString(),fanS pn.getSelectedItem().toString());
if(!unitExsits(units)) {
dbHandler.createUnit(units);
Unit.add(units);
unitsAdapter.notifyDataSetChanged();
// populateList();
// startActivity(new Intent(getApplicationContext(),HomePage.class));
Intent intent_valueBulb = new Intent(CreateNewUnit.this,
HomePage.class);
intent_valueBulb.putExtra("key2",noOfBulb);
intent_valueBulb.putExtra("keyFan",noOfFan);
startActivity(intent_valueBulb);
Toast.makeText(getApplicationContext(),String.valueOf(myTry.getText())+"has been added to units",Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(getApplicationContext(), String.valueOf(myTry.getText()) + " already exists !!! Please use a different name!", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
view = getLayoutInflater().inflate(R.layout.listview_item,parent ,false);
}
Units currentUnit = Unit.get(position);
TextView name = (TextView)view.findViewById(R.id.lblLUnitName);
name.setText(currentUnit.getName());
TextView bulb=(TextView) view.findViewById(R.id.lblLNoofBulbs);
bulb.setText("Number of Bulbs :"+currentUnit.getBulbNo());
TextView fan=(TextView) view.findViewById(R.id.lblLNoOfFans);
fan.setText("Number of Fans :"+currentUnit.getFanNo());
return view;
}