Android开发杂谈

使用数组循环下标出错:

当使用

       for(int i:数组名)

当使用一次,再次循环使用时会出现下标越界问题

ArrayList和数组

ArrayList、List、数组之间的区别,用数组存储Button时会出现出错,但是使用ArrayList<Button>存储Button操作则很顺利通过。

Android Device Monitor

当使用Android Studio 3.0以上版本时,无法通过Tools--Android 打开Android Device Monitor,先安装Java 的JDK,然后配置JAVA_HOME变量:

新建一个系统变量

变量名:JAVA_HOME

值:JDK安装的路径;

找到系统变量Path

点击编辑

Path变量名不变

在值的后面加上

%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

然后找到Android的SDK文件夹,一般在USER\AppData\Local\Android\Sdk,进入tools,找到monitor.bat,双击打开等约1-5秒就可以打开DDMS了。

LinearLayout问题:

当使用线性布局时,如何像百分比布局那样,使控件一一对齐呢?

诀窍就是把控件设置一个宽度值,之后再设定layout_weight值。

 <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:orientation="horizontal"
            android:weightSum="3">

            <TextView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:text="@string/thisMonthStand"
                android:layout_weight="1"

                />

            <TextView
                android:id="@+id/thisMonthStand"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="当前数据"
                android:layout_weight="2"
                />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:orientation="horizontal"
            >

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="@string/lastMonthSurplus"
                android:layout_weight="1"
                android:gravity="left"

                />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="当前数据"
                android:layout_weight="2"
                />

        </LinearLayout>

Android Studio使用ADB 查询数据库问题:

1、ADB要使用先要加环境变量Path,路径是:“\Android\SDK\platform-tools”

2、数据库是在/data/data/包名/databases/ 下,记得用cd命令进入时两边的   "/"  都要输入

3、sqlit3使用SQL命令查询时记得命令后面有    "';"  例如:

select * from BOOK;

猜你喜欢

转载自blog.csdn.net/sharpeha/article/details/88692845