Reputation: 11
am working in android. Am using NumberPicker
which i got from here i want the input value taken from the NumberPicker
should be displayed in the TextView
which i have written in different class
.. how can i do this.. please help.. here is a code..
public class home_try extends Activity {
private NumberPicker numberpicker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dummy1);
final Dialog textDialog = new Dialog(this);
Button setpoint= (Button) findViewById(R.id.button2);
setpoint.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
textDialog.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
textDialog.getWindow().setLayout(300, 200);
textDialog.setTitle("Set Temperature");
LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View myView = li.inflate(R.layout.main, null);
textDialog.setContentView(myView);
textDialog.show();
}
});
Button set=(Button) findViewById(R.id.button1);
set.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.dummy1);
}
});
}
Upvotes: 0
Views: 3463
Reputation: 2844
The android's numberpicker is a custom view that contains two buttons and a textview. If you can put a complete control on the numberpicker, you can make your own custom numberpicker view, and add a getter method that returns its textbox, or, text of the textbox. you can download the android source code for number picker from here. do not forget to add numberpicker layout xml file from here.
Upvotes: 0
Reputation: 6115
pass the value along intetnt using putExtra and by getting it in next class(Activity) you can set that value using setText() method......
Upvotes: 0
Reputation: 33545
Assuming you've used the widget right....
NumberPicker numPicker = (NumberPicker)findViewById(R.id.whatever);
int value = numPicker.getValue();
tvTextView.setText(String.valueOf(value));
Upvotes: 3