小编Sci*_*cit的帖子

如何禁用布局中的所有视图?

例如,我有:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
        android:layout_height="fill_parent">
     <Button 
        android:id="@+id/backbutton"
        android:text="Back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <LinearLayout
        android:id="@+id/my_layout"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/my_text_view"
            android:text="First Name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/my_edit_view"
            android:width="100px"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" /> 
        <View .../>
        <View .../>
        ...
        <View .../>
    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

有没有办法禁用(setEnable(false))LinearLayout中的所有元素my_layout

android android-layout

69
推荐指数
11
解决办法
9万
查看次数

Android中的Timer和TimerTask

我的程序需要一个计时器.我写了它,它在仿真器程序(Android 1.5/2.2)中的PC上工作正常.但它不适用于真实设备(Android 1.5).我究竟做错了什么?

TimerTask task = new TimerTask() {
            public void run() {
                if (condition) {
                    myFunc();
                } else {
                    this.cancel();
                }
            }
        };
        Timer timer = new Timer();
        timer.schedule(task, 500, 85);
Run Code Online (Sandbox Code Playgroud)

android timer timertask

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

OnClickListener不适用于可点击属性

所以,我的问题是OnClickListener当我android:clickable="true"进入我的班级时不起作用.

这是MyClassxml代码:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background"
    android:clickable="true">
...
...
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

MyClass.java:

public class MyClass extends RelativeLayout implements OnClickListener {
    public MyClass(Context context) {
        super(context);

        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.book_item, this);
        setOnClickListener(this);
    }

    public void onClick(View v) {
        Log.v("TAG", "Hello");
    }
...
...
}
Run Code Online (Sandbox Code Playgroud)

当我设置android:clickable为false 时,它工作正常.我错了什么?

android onclicklistener android-relativelayout

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

Android键盘.Key的背景

如何在Android键盘上为每个键设置背景. KeyboardView android:keyBackground为所有键提供一个背景.但我想为每个键设置不同的背景.

keyboard android

8
推荐指数
2
解决办法
7369
查看次数

在Git中更改免费和付费应用程序风味的Android软件包名称

我开发了同一个应用程序的两个版本:免费和付费版本.两个分支都基于Git中的"主"分支.有时我将master分支合并为"free"和"paid"分支以使它们保持最新状态.但是,免费和付费应用程序必须具有不同的包名称.它不会混淆git提交历史记录,或者我应该在应用程序建筑物之前临时重命名包名称并在Git中保留原始包名称吗?

git android gradle android-gradle-plugin package-name

3
推荐指数
1
解决办法
310
查看次数