맞춤 번호 선택 도구를 만들려고하는데 + 또는 - 버튼을 클릭 할 때마다 앱이 다운됩니다. MainActivity.java에서 오류가 발생하지 않습니다. 누군가가 어떤 상황인지 알 수 있습니까? 당신은 인수로 CharSequence
을 기대 setText
메소드를 호출 할 필요가버튼을 클릭하면 앱이 깨집니다.
public class MainActivity extends Activity {
TextView tvHeight;
int counter = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button heightMinus = (Button) findViewById(R.id.height_min);
Button heightPlus = (Button) findViewById(R.id.height_plus);
tvHeight = (TextView) findViewById(R.id.textViewHeight);
heightPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter++;
tvHeight.setText(counter);
}
});
heightMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter--;
tvHeight.setText(counter);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
logcat 출력을 살펴 보았습니까? – donfuxx
왜 이것을 'numberpicker'에 태그 했습니까? – Raghunandan