小编Eri*_*Lin的帖子

RelativeLayout的layout_above给出"找不到资源"错误

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
  <ListView
      android:layout_above="@id/btn_4"    <-- this line error: No resource found
      android:layout_width="match_parent"
      android:layout_height="200dp" />
  <Button android:id="@+id/btn_4"         <-- I declare the id here
      android:layout_alignParentBottom="true"
      android:layout_height="wrap_content"
      android:layout_width="match_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

有什么建议?

android android-layout android-relativelayout

11
推荐指数
1
解决办法
5889
查看次数

静态方法调用Toast.makeText

我有一个在C++中运行的线程,当某些条件满足时,它将调用我的UI线程(Java)静态方法.调用静态方法时,我希望在我的UI上显示Toast.我试过的是:

1

     static void myMethod(){
        Toast.makeText(context, "message", Toast.LENGTH_SHORT).show();
        (I have a static context reference in global scope)
     }
Run Code Online (Sandbox Code Playgroud)

结果:

     E/AndroidRuntime( 1331): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
Run Code Online (Sandbox Code Playgroud)

2

     static void myMethod(){
         runOnUiThread(new Runnable(){
             public void run(){
                Toast.makeText(Context, "message", Toast.LENGTH_SHORT).show();
             }
         });
Run Code Online (Sandbox Code Playgroud)

结果:

   Can not compile: Cannot make a static reference to the non-static method runOnUiThread(Runnable) from the type Activity
Run Code Online (Sandbox Code Playgroud)

有人可以对此有所了解吗?非常感谢你.

android

5
推荐指数
2
解决办法
2万
查看次数

如何在Android框架中打印日志消息

我试图在核心Android框架文件中打印日志消息.例如,我尝试在MediaRecorderClient.cpp下面记录消息frameworks\base\media\libmediaplayerservice\.我试过LOGV,LOGE,LOGD,printf,和__android_log_print,没有任何成功.

我应该使用哪个命令来打印日志消息?

java-native-interface logging android native-code mediarecorder

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