小编Din*_*ata的帖子

java.lang.ClassCastException:android.app.Application无法强制转换为greendroid.app.GDApplication

我正在获得一个类强制转换异常

java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication

当我在我的项目中尝试使用绿色机器人库时.这是相关的代码.我一直试图弄清楚出了什么问题,但仍然没有运气.任何形式的帮助将不胜感激.谢谢.

public class MainMenu extends GDActivity{
   private QuickActionWidget mBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setActionBarContentView(R.layout.mainmenu);
       mBar = new QuickActionBar(this);
       mBar.addQuickAction(new QuickAction(this, R.drawable.food, "food"));

Button foodButton=(Button)findViewById(R.id.food);




foodButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
     mBar.show(v);

}
 });


}

  }
Run Code Online (Sandbox Code Playgroud)

这是我的mainmenu.xml

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back"
android:orientation="vertical" >
<RelativeLayout 

    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<RelativeLayout 
   android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android classcastexception greendroid

7
推荐指数
1
解决办法
1万
查看次数

视频录制在 Nougat 7.1 android 中的 webview Android 中不起作用

即使在覆盖 webchromeclient 中的 onPermissionRequest 并调用 request.grant(request.getResources()) 之后,Android webview 中的 android.webkit.resource.video_capture 权限也不允许 javascript 使用相机;在里面。

该代码适用于 Android 7.0,但不适用于 Android 7.1。控制台输出 [ERROR:web_contents_delegate.cc(178)] WebContentsDelegate::CheckMediaAccessPermission:不支持。在 Android 7.1 上

牛轧糖版本。

我已经在manifest中声明了权限并实现了Android 6.0及更高版本的运行时权限。

android webview chromium android-camera android-7.1-nougat

6
推荐指数
0
解决办法
589
查看次数

如何在android中显示来自输入流的svg图像?

如何在android中将svg xml字符串显示为图像?我遇到的示例加载了 drawable 文件夹中已经存在的图像,但在我的情况下,svg 数据在字符串中?。

svg android

5
推荐指数
0
解决办法
617
查看次数

canvas中的rotate()无效

当我将canvas方法与canvas对象一起使用时,canvas对象不会旋转.为什么会这样?这是我的代码

package com.example.hello;

    import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.os.Bundle; import android.view.View; import android.widget.LinearLayout;

    public class CanvasDrawExample extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
    setContentView(R.layout.example);
    LinearLayout rl=(LinearLayout)findViewById(R.id.rl);
     rl.addView(new CircleView(this));
    }
public class CircleView extends View
{

    public CircleView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub


    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub


        Paint p=new Paint(Paint.ANTI_ALIAS_FLAG);
        p.setStrokeWidth(100);
        p.setStyle(Paint.Style.STROKE);
        p.setColor(Color.BLUE);

        canvas.drawRect(200, 100, 200, …
Run Code Online (Sandbox Code Playgroud)

android android-animation android-canvas

0
推荐指数
1
解决办法
2301
查看次数