MjpegView与其他XML布局 [英] MjpegView with other XML layouts

查看:237
本文介绍了MjpegView与其他XML布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发需要通过MJPEG得到一个Airdrone流的应用程序。

I'm developing an APP that needs to gets the stream of an Airdrone through mjpeg.

我使用的是类从这个话题。它的伟大工程的例子,但我需要加入一些其他元素,同样的看法,如按钮来控制德airdrome。

I'm using the classes from this topic. It works great with the example but I need to add some other elements to the same view such as the buttons to control de airdrome.

这个例子code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    mv = new MjpegView(this);
    setContentView(mv);
    ...

我想要做的,但不工作...

What i'm trying to do but is not working...

...
mv = (MjpegView) findViewById(R.id.mv);
setContentView(R.layout.activity_test);
...

和我的布局XML ...

And my layout xml...

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    tools:context="com.gabilheri.rosbridgecontroller.app.TestActivity"
    android:layout_height="fill_parent"
    android:id="@+id/mainLayout">
    <com.gabilheri.rosbridgecontroller.app.VideoStreamClasses.MjpegView
        android:id="@+id/mv"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />
</FrameLayout>

这是logcat的错误:

This is the LOGCAT error:

04-26 22:40:19.521    2229-2229/com.gabilheri.rosbridgecontroller.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.gabilheri.rosbridgecontroller.app, PID: 2229
java.lang.NullPointerException
        at com.gabilheri.rosbridgecontroller.app.TestActivity$DoRead.onPostExecute(TestActivity.java:86)
        at com.gabilheri.rosbridgecontroller.app.TestActivity$DoRead.onPostExecute(TestActivity.java:59)
        at android.os.AsyncTask.finish(AsyncTask.java:632)
        at android.os.AsyncTask.access$600(AsyncTask.java:177)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5184)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1015)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
        at dalvik.system.NativeStart.main(Native Method)

这是从方法行onPOST等执行:

This are the lines from the method onPost execute:

mv.setSource(result);  //Line 86
mv.setDisplayMode(MjpegView.SIZE_BEST_FIT); // Line 87
mv.showFps(true); // Line 88

任何人有什么想法?谢谢! :D

Anyone have any ideas? Thank you! :D

推荐答案

我想通了什么是我的问题...

I figured it out what was my problem...

我试图做的:

mv = (MjpegView) findViewById(R.id.mv);
setContentView(R.layout.activity_test);

和渐渐NullPointerException异常。我更改为:

And was getting a NullPointerException.. I changed to:

setContentView(R.layout.activity_test);
mv = (MjpegView) findViewById(R.id.mv);

而现在一切工作像应该是:)

And now everything is working like is supposed to be :)

这篇关于MjpegView与其他XML布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆