小编met*_*ter的帖子

Android:四个方块的对齐方式

我试图在Android屏幕上对齐四个相同大小的正方形,我现在尝试了几百万种不同的方法,但它们似乎都没有工作:(.

我现在得到的是以下内容:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/MasterLayout" android:layout_width="wrap_content"     android:layout_height="fill_parent"  android:background="#FFFFFF">
<TableLayout android:layout_width="fill_parent" android:id="@+id/mainlay" android:background="#444444" android:layout_weight="0.2" android:layout_height="wrap_content" android:padding="0dip">
    <TableRow android:layout_weight="1"  android:background="#BBBBBB" android:padding="0dip">
        <ImageView android:id="@+id/ImageView1" android:layout_marginLeft="10px" android:layout_weight="1" android:layout_marginRight="5px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
        <ImageView android:id="@+id/ImageView2" android:layout_marginLeft="5px" android:layout_weight="1" android:layout_marginRight="10px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
    </TableRow>
    <TableRow android:layout_weight="1" android:padding="0dip">
        <ImageView android:id="@+id/ImageView3" android:layout_marginLeft="10px" android:layout_weight="1" android:layout_marginRight="5px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
        <ImageView android:id="@+id/ImageView4" android:layout_marginLeft="5px" android:layout_weight="1" android:layout_marginRight="10px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
    </TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这基本上完成了这项工作.但是,这四个图像中的每一个都在其上方和下方都有一个巨大的填充.我怎么摆脱它?或者我是否需要一起使用不同的布局类型?

为了帮助说明我的问题,这是一张图片.左边是我得到的,右边是我需要的. 图片

非常感谢你!

干杯,马库斯!

java xml layout android

9
推荐指数
1
解决办法
1074
查看次数

Android onActivityResult.成员变量有时为null

我写了一个应用程序,现在,发布后,我的一些用户似乎遇到了一个令人讨厌的错误.一个我根本无法重现的.

参与其中的是三项活动.

活动1:SuperActivity

public abstract class SuperActivity extends Activity
Run Code Online (Sandbox Code Playgroud)

活动2:MainActivity

public class MainActivity extends SuperActivity {

  private MyObject myMemberVariable;    

  @Override
  public void onCreate(Bundle savedInstanceState) {

    //Get the intent that started this activity. I am always providing Extras, so this is never null.
    Bundle bundle = getIntent().getExtras();

    //Set stuff in myMemberVariable from these extras. This never fails either.
    myMemberVariable = BundleLoader.loadFromBundle(bundle);

  }


  @Override
  public void onListDialogClick(int requestCode, String[] options, int position, String extra) {
    //THIS is the place where, according to …
Run Code Online (Sandbox Code Playgroud)

null android pointers exception

9
推荐指数
1
解决办法
2704
查看次数

Android上的Couchbase lite - 一般架构?

我们正在使用couchbase构建一个项目.在Android上,我使用couchbase lite.通常,我一直在使用关系数据库,因为我是沙发基础新手,我无法找到"正确"的架构.我理解我认为的核心概念,但所有的示例和指南似乎都坚持某种简单的设置,他们在活动中访问数据库.

我更习惯于拥有一些数据库抽象,其中业务逻辑只能看到通过数据库接口或某些DAO或其他东西传递的POJO DTO.所以我现在已经注释了我的模型类并开始编写一个简单的OR映射器,但是使用不同类型的数据,外键等等,这非常耗时.

我在某种程度上完全忽略了这一点吗?我无法想象每个人都这样做吗?我每个人都在编写将文档单独转换为每个类的POJO模型类的方法吗?或者使用json解析器来做到这一点(但如果我不想加载外键那么这对外键不起作用,是吗?)?

很抱歉问题很多,但我觉得我错过了一些明显的问题.谢谢!

database architecture android couchbase

6
推荐指数
1
解决办法
580
查看次数

标签 统计

android ×3

architecture ×1

couchbase ×1

database ×1

exception ×1

java ×1

layout ×1

null ×1

pointers ×1

xml ×1