㈠ android单选按钮
你要当成单选的一组的radiobutton要放在radioGROUP下,不然这个GROUP就没起作用
只有这样写,才能实现这组radiobutton是单选的效果。
㈡ android listview单选如何获取当前选中是否勾选
1、使用checked属性判断选中,代码为if($(this).attr("checked")){alert("选中了");}。
2、jquery获取radio单选按钮的值。以上就是androidlistview单选获取勾选当前选中指的方法。
㈢ android布局listview中怎么样设置下拉与单选按钮
android里面没有表格,只有列表,要做到这样的效果很麻烦的。
android里面的ui是适合手机的,这种列表,特别是右边的那个下拉按钮,不适合手机这种屏幕小的设备。比如说下拉,android里面用的是spinner,通常是屏幕居中弹出,当然也可以设置下拉,设置下拉屏幕的利用不高啊,要显示完数据都不容易。
也就是说这种针对PC的界面设计,建议你最好做一些调整来符合android的特性。当然,如果真的要实现,也是可以实现的。
左边的就是checkBox,最右边可以用Spinner,也可以自定义或用其它View来实现 ,比如说Button,左drawable,右drawable,点击后弹出popWindow.
至于这种样式,最好是把listView放在RelativeLayout中,把线条画在listView上,模拟出表格样式。
㈣ android单选按钮
你要当成单选的一组的radiobutton要放在radioGROUP下,不然这个GROUP就没起作用
只有这样写,才能实现这组radiobutton是单选的效果。
㈤ 如何实现android中三个单选按钮横向排列且只能选一个
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/row_item_margin">
<TextView
android:id="@+id/tvStorageWay"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="储存方式:"/>
<RadioGroup
android:id="@+id/rgStorageWay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/tvStorageWay"
android:gravity="center_vertical"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rbPack"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="包装"/>
<RadioButton
android:id="@+id/rbBulk"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="散装"/>
<RadioButton
android:id="@+id/rbStorageWayOther"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="其它"/>
</RadioGroup>
</RelativeLayout>
㈥ Android-RadioButton单选按钮控件详解
RadioButton是单选按钮,允许用户在一个组中选择一个选项。同一组中的单选按钮有互斥效果。
1.RadioButton是圆形单选框;
2.RadioGroup是个可以容纳多个RadioButton的容器;
3.在RadioGroup中的RadioButton控件可以有多个,但同时有且仅有一个可以被选中。
基本的使用就是上面Demo说的那样。在Android开发当中,我们也可以使用RadioButton控件来实现应用的底部导航栏。
㈦ Android studio 单选按钮怎么更改点击后的样式
button设置null之后再设置background,自己创建个selector就行了
㈧ android 用imageview实现单选功能
imageView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
v.setBackgroundResource(null); v.setBackgroundResource(R.drawable.adddoorbellon);
ImageView imageView = (ImageView) findViewById(R.id.yimenling_oneclick);
imageView.setBackgroundResource(R.drawable.akeyconfiguration);
}
});
这样试试,,最好把你的错误日志发出来
㈨ 关于Android界面组件的基本用法
1.文本框(TextView)和编辑框(EditText)
文本框(TextView)不允许用户编辑文本内容,而编辑框(EditText)允许用户编辑文本内容
2.按钮(Button)和图片按钮(ImageButton)
Button显示文字,ImageButton显示图片。
为ImageButton指定android:text属性没用,不会显示文字
可以指定android:background为按钮增加背景图片,但这图片是固定的
可以指定android:src为图片按钮增加图片属性
其实,src才是设置图标,而background只是设置背景。
如果控件的大小是100 100 图片资源是80 80的话,那么用src,图片就会居中显示,如果使用background那么图片就会被拉伸充满控件。
重要的是,background是底层的图片资源,src是覆盖在background上面的资源,他们可以叠加使用,实现选中的效果。
3.单选按钮(RadioButton)和复选框(CheckBox)
多了一个android:checked属性,用于指定初始时是否被选中
4.计时器组件Chronometer用法
红色字体表示常用的方法
5.图像视图(ImageView)
它支持属性android:scaleType setScaleType(ImageView.ScaleType)
matrix(ImageView.ScaleType.MATRIX):使用matrix方式进行
fixXY(ImageView.ScaleType.FIX_XY):对图片横向纵向独立缩放,会改变纵横比
fitStart(ImageView.ScaleType.FIT_START):保持纵横比,图片较长的边长与ImageView相应的边长相等,缩放后放在左上角
fitCenter(ImageView.ScaleType.FIT_CENTER):保持纵横比,图片较长的边长与ImageView相应的边长相等,缩放后放在中央
fitEnd(ImageView.ScaleType.FIT_END):保持纵横比,图片较长的边长与ImageView相应的边长相等,缩放后放在右下角
center(ImageView.ScaleType.CENTER):放中间,不缩放
centerCrop(ImageView.ScaleType.CENTER_CROP):保持纵横比,使图片能完全覆盖ImageView
centerInside(ImageView.ScaleType.CENTER_INSIDE):保持纵横比,使ImageView能完全显示图片
6.spinner的功能和用法
如果可以确定spinner里面的列表项,那么直接在/res/layout/main.xml里面指定
然后在/res/value/string.xml里面指定
如果不确定里面的列表项,那么必须要提供一个Adapter,这个Adapter负责决定Spinner列表每项的内容
7.日期、时间选择器(DatePicker和TimePicker)
8.自动完成文本框(AutoCompleteTextView)
比普通文本框多了一个功能:当用户输入一定字符后,自动完成文本框会显示一个下拉菜单,供用户从中选择,当用户选择某个菜单后,组件会按用户选择自动填写该文本框
使用该组件很简单,只要为它设置一个Adapter,该Adapter封装了AutoCompleteTextView预设的提示文本
9.进度条(ProgressBar)
通过style属性可以为ProgressBar指定风格。该属性可以有如下的属性值:
1.@android:style/Widget.ProgressBar.Horizontal 水平进度条
2.@android:style/Widget.ProgressBar.Inverse 不断跳跃、旋转画面的进度条
3.@android:style/Widget.ProgressBar.Large 大进度条
4.@android:style/Widget.ProgressBar.Large.Inverse不断跳跃、旋转画面的大进度条
5.@android:style/Widget.ProgressBar.Small 小进度条
6.@android:style/Widget.ProgressBar.Small.Inverse不断跳跃、旋转画面的小进度条
ProgressBar提供如下方法来操作进度
1.setProgress(int) 设置进度的完成百分比
2.incrementProgressBy(int) 设置进度条的增加或减少。参数为正增加,参数为负减少
10.选项卡(TabHost)
TabHost仅仅只是一个简单的容器,它提供如下方法
1.newTabSpec(String tag) 创建选项卡
2.addTab(TabHost.TabSpec tabSpec) 添加选项卡
使用TabHost的一般步骤为:
• A. 在界面中定义TabHost组件,并为该组件定义该选项卡的内容
• B. Activity应该继承TabActivity
• C. 调用TabActivity的getTabHost()来获取TabHost对象
• D. 通过TabHost对象的方法来创建选项卡、添加选项卡
选项卡主要由TabHost、TabWidget、FrameLayout3个组件组成,三者缺一不可,想象一下选项卡的特点,多个卡重叠在一起,所以用FrameLayout即帧布局是必要的。另外需要注意的是TabHost、TabWidget、FrameLayout三个组件的android:id必须使用系统默认的名称,而不能自己随意定义,否则会出错。
11.图像切换器(ImageSwitcher)
12.网格视图(GridView)
使用GridView一般指定numColumn大于1,否则取默认值为1.那么GridView就变成了ListView
属性android:stretchMode支持如下属性
1.none 不拉伸
2.spacingWidth 仅拉伸元素之间的间距
3.spacingWidthUniform 表格、元素之间的间距一起拉伸
4.columnWidth 仅拉伸表格
13.画廊视图(Gallery)(现在已经被弃用了,不过还是列出来吧)
Gallery用法很简单——为它提供一个内容Adapter,该Adapter的getView方法所返回的View可作为Gallery的列表项。可以通过OnItemSelectedListener监听选择项的改变
14.列表试图(ListView和ListActivity)
1.创建ListView由两种方式:
2.直接使用ListView进行创建
让Activity继承ListActivity(继承了ListActivity的类无需调用setContentView()来显示页面,可以直接设置适配器)
一旦获得ListView后,就要创建显示的列表项了。需要借助内容Adapter,内容Adapter负责提供需要显示的列表项
创建ArrayAdapter时必须指定一个textViewResourceId,该参数决定每个列表项的外观
1.simple_list_item_1 每个列表项是普通的TextView
2.simple_list_item_2 每个列表项是普通的TextView(字体略大)
3.simple_list_item_checked 每个列表项是已勾选的列表项
4.simple_list_item_multiple_choice 每个列表项是带多选框的文本
5.simple_list_item_single_choice 每个列表项是带多单选按钮的文本
15.使用AlertDialog
1.创建AlertDialog.Builder对象,该对象是AlertDialog的创建器
2.调用AlertDialog.Builder方法为对话框设置图标、标题等
3.调用AlertDialog.Builder的create()方法创建AlertDialog对话框
4.调用AlertDialog的show()方法显示对话框
16.使用Toast显示提示框
步骤如下:
• 调用Toast构造器或makeText方法创建Toast对象
• 调用Toast方法来设置该消息的对齐方式等
• 调用Toast的show()方法显示出来
• Toast toast = Toast.makeText(ToastTest.this, "信息", Toast.LENGTH_LONG).show();
17.Notification(一般显示网络状态、电池状态、时间等)
使用Notification发送Notification步骤:
• 调用getSystemService(NOTIFICATION_SERVICE)方法获取系统的Notification Manager服务
• 通过构造器创建一个Notification对象
• 为Notification设置属性
• 通过Notification Manager发送Notification
㈩ 求 android RadioButton属性详解
一: 单选按钮RadioButton在Android平台上也应用的非常多,比如一些选择项的时候,会用到单选按钮,实现单选按钮由两部分组成,也就是RadioButton和RadioGroup配合使用
RadioButton的单选按钮;
RadioGroup是单选组合框,用于将RadioButton框起来;
在没有RadioGroup的情况下,RadioButton可以全部都选中;
当多个RadioButton被RadioGroup包含的情况下,RadioButton只可以选择一个;
注意:单选按钮的事件监听用setOnCheckedChangeListener来对单选按钮进行监听
例子:一道选择题,选择哪个城市美女最多,当然,这个就是为了测试
Java代码
1.package org.loulijun.radio;
2.
3.import android.app.Activity;
4.import android.os.Bundle;
5.import android.view.Gravity;
6.import android.widget.RadioButton;
7.import android.widget.RadioGroup;
8.import android.widget.TextView;
9.import android.widget.Toast;
10.
11.public class RadioTest extends Activity {
12. /** Called when the activity is first created. */
13. TextView textview;
14. RadioGroup radiogroup;
15. RadioButton radio1,radio2,radio3,radio4;
16. @Override
17. public void onCreate(Bundle savedInstanceState) {
18. super.onCreate(savedInstanceState);
19. setContentView(R.layout.main);
20. textview=(TextView)findViewById(R.id.textview1);
21. radiogroup=(RadioGroup)findViewById(R.id.radiogroup1);
22. radio1=(RadioButton)findViewById(R.id.radiobutton1);
23. radio2=(RadioButton)findViewById(R.id.radiobutton2);
24. radio3=(RadioButton)findViewById(R.id.radiobutton3);
25. radio4=(RadioButton)findViewById(R.id.radiobutton4);
26.
27. radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
28.
29. @Override
30. public void onCheckedChanged(RadioGroup group, int checkedId) {
31. // TODO Auto-generated method stub
32. if(checkedId==radio2.getId())
33. {
34. DisplayToast("正确答案:"+radio2.getText()+",恭喜你,回答正确!");
35. }else
36. {
37. DisplayToast("请注意,回答错误!");
38. }
39. }
40. });
41. }
42. public void DisplayToast(String str)
43. {
44. Toast toast=Toast.makeText(this, str, Toast.LENGTH_LONG);
45. toast.setGravity(Gravity.TOP,0,220);
46. toast.show();
47. }
48.}
strings.xml文件
Xml代码
1.<?xml version="1.0" encoding="utf-8"?>
2.<resources>
3. <string name="hello">哪个城市美女多?</string>
4. <string name="app_name">单选按钮测试</string>
5. <string name="radiobutton1">杭州</string>
6. <string name="radiobutton2">成都</string>
7. <string name="radiobutton3">重庆</string>
8. <string name="radiobutton4">苏州</string>
9.</resources>
main.xml文件:注意,这里面,4个RadioButton包含在RadioGroup中
Xml代码
1.<?xml version="1.0" encoding="utf-8"?>
2.<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3. android:orientation="vertical"
4. android:layout_width="fill_parent"
5. android:layout_height="fill_parent"
6. >
7.<TextView
8. android:layout_width="fill_parent"
9. android:layout_height="wrap_content"
10. android:text="@string/hello"
11. android:id="@+id/textview1"
12. />
13. <RadioGroup
14. android:id="@+id/radiogroup1"
15. android:layout_width="wrap_content"
16. android:layout_height="wrap_content"
17. android:orientation="vertical"
18. android:layout_x="3px"
19. >
20. <RadioButton
21. android:id="@+id/radiobutton1"
22. android:layout_width="wrap_content"
23. android:layout_height="wrap_content"
24. android:text="@string/radiobutton1"
25. />
26. <RadioButton
27. android:id="@+id/radiobutton2"
28. android:layout_width="wrap_content"
29. android:layout_height="wrap_content"
30. android:text="@string/radiobutton2"
31. />
32. <RadioButton
33. android:id="@+id/radiobutton3"
34. android:layout_width="wrap_content"
35. android:layout_height="wrap_content"
36. android:text="@string/radiobutton3"
37. />
38. <RadioButton
39. android:id="@+id/radiobutton4"
40. android:layout_width="wrap_content"
41. android:layout_height="wrap_content"
42. android:text="@string/radiobutton4"
43. />
44. </RadioGroup>
45.</LinearLayout>
二:Android 自定义RadioButton的样式(和上面关系不大)
我们知道Android控件里的button,listview可以用xml的样式自定义成自己希望的漂亮样式。
最近用到RadioButton,利用xml修改android:background="@drawable/button_drawable",其中button_drawable为自己定义的.xml文件(res/drawable文件下),但是不成功,到网上查找,也没有正确的说法,我就开始自己尝试,最后做好了。
其实方法很简单,同样在res/drawable新建radiobutton.xml如下
Xml代码
1.<selector xmlns:android="http://schemas.android.com/apk/res/android">
2.
3. <item
4.
5.
6. android:state_enabled="true"
7.
8. android:state_checked="true"
9.
10. android:drawable="@drawable/check" />
11.
12. <item
13.
14. android:state_enabled="true"
15.
16. android:state_checked="false"
17.
18. android:drawable="@drawable/checknull" />
19.
20. </selector>
check和checknull分别为选中和位选中的图片。
然后在你的布局文件中,RadioButton 布局
设置android:button = "@drawable/radiobutton",就可以了!