美文网首页
android报错You need to use a Theme

android报错You need to use a Theme

作者: Chentt的技术博客 | 来源:发表于2015-12-16 13:34 被阅读225次

    报错如下:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test2/com.example.test2.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

    解决方法:

    创建的activity是MainActivity extends ActionBarActivity这样的。把后面的ActionBarActivity改成Activity,然后导包,把下面报错的地方删掉运行就不报错了。。。


    感应器在Android 1.5 API Level 3 使用了SensorEventListener 代替了SensorListener

    而新的方法如下

    private SensorEventListener sel = new SensorEventListener()

    {

    public void onSensorChanged(SensorEvent event)

    {

    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)

    {

    event.values; //float[]保存了x,y,z

    }

    }

    public void onAccuracyChanged(Sensor sensor, int accuracy){

                     }

    };

    Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    sensorManager.registerListener(sel, sensor, SensorManager.SENSOR_DELAY_NORMAL);

    相关文章

      网友评论

          本文标题:android报错You need to use a Theme

          本文链接:https://www.haomeiwen.com/subject/zxzuhttx.html