关于ListActivity中的CheckBox

Android 码拜 9年前 (2015-04-27) 824次浏览 0个评论
 

我在列表中列出一队内容,每一栏左边应该有个CheckBox,但是在一般情况下不要显示它。

在按了“编辑”键才显示它,同时将原来的内容往右推开。

请问怎么做呢?


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
    
    <RelativeLayout
        android:id="@+id/relative_20" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
    
    	<CheckBox 
        	android:id="@+id/select" 
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_centerVertical="true"
	    	android:layout_marginLeft="5dp"
        	/>
    
	    <RelativeLayout
    	    android:id="@+id/relative_21" 
        	android:layout_width="match_parent"
        	android:layout_height="wrap_content"
	    	android:layout_marginLeft="35dp"
        	>
    
    		<TextView
	        	android:id="@+id/caption"
        		android:layout_width="wrap_content"
        		android:layout_height="wrap_content"
        		/>

	    	<TextView
		        android:id="@+id/datetime"
    		    android:layout_width="wrap_content"
        		android:layout_height="wrap_content"
        		android:layout_below="@+id/caption"
        		/>

    		</RelativeLayout>
    
	    <RelativeLayout
    	    android:id="@+id/relative_22" 
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
	    	android:layout_marginRight="10dp"
        	android:layout_alignParentRight="true"
        	>
    
    	<TextView
	        android:id="@+id/date"
    	    android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
    	    />

    	<TextView
        	android:id="@+id/time"
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_below="@+id/date"
        	/>
    
    	</RelativeLayout>
	    
    	<RelativeLayout
	        android:id="@+id/relative_23" 
    	    android:layout_width="match_parent"
        	android:layout_height="wrap_content"
        	android:layout_below="@+id/relative_21"
	    	android:layout_marginLeft="35dp"
        	>
    
	    <TextView
    	    android:id="@+id/remark"
        	android:layout_width="match_parent"
        	android:layout_height="wrap_content"
        	/>
    
    	</RelativeLayout>
	    
    </RelativeLayout>
    
</RelativeLayout>


这是我的界面设计,我想关键点是,这个marginLeft能不能通过程序重设一下?

android:layout_marginLeft=”35dp”

关于ListActivity中的CheckBox
30分
那你可以试着给 checkbox 设置一个属性,visibility=gone;
关于ListActivity中的CheckBox
10分
2楼说的对,设置在checkbox布局设置visibility=gone,右侧部分相对checkbox布局,长按后显示checkbox即可

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明关于ListActivity中的CheckBox
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!