============問題描述============
??<TextView
????????android:id="@+id/textview1"
????????android:layout_columnSpan="4"
????????android:layout_gravity="fill"
????????android:gravity="right"
????????android:text="0"?/>
public?class?MainActivity?extends?Activity?{
Button?one;
TextView?text1;
????@Override
????protected?void?onCreate(Bundle?savedInstanceState)?{
????????super.onCreate(savedInstanceState);
????????one=(Button)findViewById(R.id.one);
????????text1=(TextView)findViewById(R.id.textview1);
????????setContentView(R.layout.activity_main);
????}
????public?void?clickone(View?v){
???? double?n=Double.parseDouble(text.getText().toString());
????if(n!=0)
???? text1.setText(text1.getText()+"1");
???? else
???? text1.setText("1");
????
????}
在主函數中各種方法都崩潰
============解決方案1============
one=(Button)findViewById(R.id.one);
?text1=(TextView)findViewById(R.id.textview1);
這兩句放setContentView(R.layout.activity_main);下面試試