我在android工作。使用NumberPicker
我从here获得的NumberPicker
我希望从TextView
获取的输入值应该显示在我用不同class
编写的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);
}
});
}
中..我怎么能这样做..请帮忙..这是一个代码..
{{1}}
答案 0 :(得分:3)
假设您已正确使用了小部件....
NumberPicker numPicker = (NumberPicker)findViewById(R.id.whatever);
int value = numPicker.getValue();
tvTextView.setText(String.valueOf(value));
答案 1 :(得分:0)
使用putExtra将值传递给intetnt,并通过在下一个类(Activity)中获取它,您可以使用setText()方法设置该值......
答案 2 :(得分:0)