"unfortunately application has stopped" error poping up in eclipse while running app. i am using API17, i did everything. but still i have same problem...this bug wasted my whole day.
这是activity_main.xml。被这个 bug 弄疯了。请帮助一些人......我在 textview 上使用过,还有两个按钮......但是他们给出了关于视图包的错误。所以我清理了项目......但现在它告诉我应用程序已停止。
package com.example.savetouch;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
int counter;
Button pl,op;
TextView display;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
counter=0;
pl=(Button) findViewById(R.id.bplay);
op=(Button) findViewById(R.id.boption);
display=(Button) findViewById(R.id.tvdisplay);
pl.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter++;
display.setText(""+counter);
}
});
op.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
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;
}
}
it giving problem in view pakage, and text pakage.. to solve that problem i have imported android.view.view.OnClickListener.
This is activity_main.xml. gone mad by this bug.pls help some one......i have used on textview, and two buttons..but they was giving an error about view package. so i clean the project...but now it showing me that application has stopped.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/tvdisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="SAVETOUCH"
android:textSize="45sp" />
<Button
android:id="@+id/boption"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/tvdisplay"
android:layout_below="@+id/bplay"
android:text="Option"
android:textSize="20sp" />
<Button
android:id="@+id/bplay"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/boption"
android:layout_below="@+id/tvdisplay"
android:layout_marginTop="22dp"
android:text="Play"
android:textSize="20sp" />
</RelativeLayout>