当前位置: 首页 > news >正文

wordpress搭建网站店铺推广软文500字

wordpress搭建网站,店铺推广软文500字,WordPress简约主题博客,wordpress乱码我将Android控件的Button和Checkbox的学习知识总结一下和大家共享 在Android开发中&#xff0c;按钮和复选框是非常常用的控件 Button控件的基本使用方法很简单&#xff0c;在布局文件中使用<Button>既可以了&#xff0c;或者在java代码&#xff1a;Button button &…

我将Android控件的Button和Checkbox的学习知识总结一下和大家共享

在Android开发中,按钮和复选框是非常常用的控件

Button控件的基本使用方法很简单,在布局文件中使用<Button>既可以了,或者在java代码:Button button = (Button)findViewById(R.id.button1);

Checkbox也是一样的。

1、Button控件

按钮控件的最常见的是单击事件,可以通过Button.setOnClickListener方法设置处理单机事件的监听器,也可以在<Button>标签的android:onClick属性指定单击事件方法名。如果当前类实现了android.view.view.OnClickListener接口,可以直接将this传入到setOnClickListener方法。

下面看例子:

布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent" android:gravity="center_horizontal"><Button android:id="@+id/btnCommonButton" android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="我的按钮1" /><Button android:id="@+id/btnImageButton"  android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="按钮"android:gravity="center" android:background="@drawable/button1" />
</LinearLayout>
java实现文件:

public class Main extends Activity implements OnClickListener, OnTouchListener,OnFocusChangeListener, OnKeyListener
{private int value = 1;private Button imageButton;private Button commonButton;private View lastFocusview;@Overridepublic void onClick(View view){Button button = (Button) view;if (value == 1&& button.getWidth() == getWindowManager().getDefaultDisplay().getWidth())value = -1;else if (value == -1 && button.getWidth() < 100)value = 1;button.setWidth(button.getWidth() + (int) (button.getWidth() * 0.1)* value);button.setHeight(button.getHeight() + (int) (button.getHeight() * 0.1)* value);}@Overridepublic boolean onKey(View view, int keyCode, KeyEvent event){ if (KeyEvent.ACTION_DOWN == event.getAction()){view.setBackgroundResource(R.drawable.button3);}else if (KeyEvent.ACTION_UP == event.getAction()){view.setBackgroundResource(R.drawable.button2);}return false;}@Overridepublic void onFocusChange(View view, boolean hasFocus){if (hasFocus){imageButton.setBackgroundResource(R.drawable.button2);}else{imageButton.setBackgroundResource(R.drawable.button1);}}@Overridepublic boolean onTouch(View view, MotionEvent event){if (event.getAction() == MotionEvent.ACTION_UP){view.setBackgroundResource(R.drawable.button1);}else if (event.getAction() == MotionEvent.ACTION_DOWN){view.setBackgroundResource(R.drawable.button2);}return false;}@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);commonButton = (Button) findViewById(R.id.btnCommonButton);imageButton = (Button) findViewById(R.id.btnImageButton);commonButton.setOnClickListener(this);imageButton.setOnClickListener(this);imageButton.setOnTouchListener(this);imageButton.setOnFocusChangeListener(this);imageButton.setOnKeyListener(this);}
}
也可以试试图文混排的按钮:

布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent"><LinearLayout android:orientation="horizontal"android:layout_width="fill_parent" android:layout_height="120dp"><Button android:layout_width="wrap_content"android:layout_height="wrap_content" android:drawableTop="@drawable/star" android:text="按钮1" /><Button android:layout_width="wrap_content"android:layout_height="wrap_content" android:drawableBottom="@drawable/star"android:text="按钮2" android:drawablePadding="30dp" /><Button android:layout_width="wrap_content"android:layout_height="wrap_content" android:drawableLeft="@drawable/star"android:text="按钮3" /><Button android:layout_width="wrap_content"android:layout_height="wrap_content" android:drawableRight="@drawable/star"android:text="按钮4" android:drawablePadding="20dp" /></LinearLayout><Button android:id="@+id/button" android:layout_width="200dp"android:layout_height="200dp" android:layout_marginTop="10dp"   />
</LinearLayout>
java实现文件:

public class Main extends Activity
{@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);Button button = (Button) findViewById(R.id.button);SpannableString spannableStringLeft = new SpannableString("left");Bitmap bitmapLeft = BitmapFactory.decodeResource(getResources(),R.drawable.image_left);ImageSpan imageSpanLeft = new ImageSpan(bitmapLeft, DynamicDrawableSpan.ALIGN_BOTTOM);spannableStringLeft.setSpan(imageSpanLeft, 0, 4,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);SpannableString spannableStringRight = new SpannableString("right");Bitmap bitmapRight = BitmapFactory.decodeResource(getResources(),R.drawable.image_right);ImageSpan imageSpanRight = new ImageSpan(bitmapRight);spannableStringRight.setSpan(imageSpanRight, 0, 5,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);button.append(spannableStringLeft);button.append("我的按钮");button.append(spannableStringRight);}
}
接下来介绍一下ImageButton图片按钮,其实和普通按钮一样,差别在与不用文本显示,而是图片:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal" android:layout_width="fill_parent"android:layout_height="fill_parent"><ImageButton android:layout_width="wrap_content"android:layout_height="wrap_content" android:src="@drawable/button1_1" /><ImageButton  android:layout_width="wrap_content"android:layout_height="wrap_content" android:src="@drawable/button2_1" />
</LinearLayout>
这边补充介绍RadioButton选项按钮控件和ToggleButton开关状态按钮控件
<pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent"><RadioGroup android:layout_width="wrap_content"android:layout_height="wrap_content"><RadioButton android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="选项1" /><RadioButton android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="选项2" /><RadioButton android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="选项3"android:drawableLeft="@drawable/star" android:drawableTop="@drawable/circle"android:drawableRight="@drawable/star" android:drawableBottom="@drawable/circle" android:drawablePadding="20dp" /></RadioGroup>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal" android:layout_width="fill_parent"android:layout_height="fill_parent"><ToggleButton android:layout_width="wrap_content"android:layout_height="wrap_content"/><ToggleButton android:id="@+id/toggleButton" android:layout_width="wrap_content"android:layout_height="wrap_content" android:layout_marginLeft="30dp"android:textOff="打开电灯" android:textOn="关闭电灯"  />
</LinearLayout>

 

2、Checkbox控件

Checkbox复选框控件,在这里采用动态加载的方式,在xml布局文件的根节点不仅可以像<LinearLayout>,<RelativeLayout>一样的ViewGroup,也可以直接使用View,下面采用Checkbox标签。

Checkbox.xml;

<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/checkbox" android:layout_width="fill_parent"android:layout_height="wrap_content" />

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<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/button" android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="确定" />
</LinearLayout>

java文件:

public class Main extends Activity implements OnClickListener
{private List<CheckBox> checkboxs = new ArrayList<CheckBox>();@Overridepublic void onClick(View view){String s = "";for (CheckBox checkbox : checkboxs){if (checkbox.isChecked())s += checkbox.getText() + "\n";}if ("".equals(s))s = "您还没选呢!";new AlertDialog.Builder(this).setMessage(s).setPositiveButton("关闭", null).show();}@Overridepublic void onCreate(Bundle savedInstanceState){String[] checkboxText = new String[]{ "是学生吗?", "是否喜欢Android?", "买车了吗?", "打算出国吗?" };super.onCreate(savedInstanceState);LinearLayout linearLayout = (LinearLayout) getLayoutInflater().inflate(R.layout.main, null);for (int i = 0; i < checkboxText.length; i++){CheckBox checkbox = (CheckBox) getLayoutInflater().inflate(R.layout.checkbox, null);checkboxs.add(checkbox);checkboxs.get(i).setText(checkboxText[i]);linearLayout.addView(checkbox, i);}setContentView(linearLayout);Button button = (Button) findViewById(R.id.button);button.setOnClickListener(this);}
}



文章转载自:
http://dinncobuntline.stkw.cn
http://dinncofearful.stkw.cn
http://dinncohiggle.stkw.cn
http://dinncokikongo.stkw.cn
http://dinncomayan.stkw.cn
http://dinnconegroid.stkw.cn
http://dinncodeadman.stkw.cn
http://dinncotoreutic.stkw.cn
http://dinncoswine.stkw.cn
http://dinncomusicotherapy.stkw.cn
http://dinncocarillonneur.stkw.cn
http://dinncocarousal.stkw.cn
http://dinncophilologue.stkw.cn
http://dinncoimperturbability.stkw.cn
http://dinncodeodorant.stkw.cn
http://dinncourea.stkw.cn
http://dinncoexaminationist.stkw.cn
http://dinncolombard.stkw.cn
http://dinncodistent.stkw.cn
http://dinncocytogenics.stkw.cn
http://dinncomatronage.stkw.cn
http://dinncoomental.stkw.cn
http://dinncouncritical.stkw.cn
http://dinncopsychoanalytic.stkw.cn
http://dinncosubmissiveness.stkw.cn
http://dinncogummosis.stkw.cn
http://dinncoclaimant.stkw.cn
http://dinncometamere.stkw.cn
http://dinncopolecat.stkw.cn
http://dinncounipetalous.stkw.cn
http://dinncoahead.stkw.cn
http://dinncoaortography.stkw.cn
http://dinncorealistic.stkw.cn
http://dinncobestride.stkw.cn
http://dinncoethylation.stkw.cn
http://dinncolymphosarcoma.stkw.cn
http://dinncoboisterously.stkw.cn
http://dinncobildungsroman.stkw.cn
http://dinncogutter.stkw.cn
http://dinncoimam.stkw.cn
http://dinncoyesterdayness.stkw.cn
http://dinncomonologist.stkw.cn
http://dinncovocalise.stkw.cn
http://dinncomatara.stkw.cn
http://dinncochancre.stkw.cn
http://dinncogerard.stkw.cn
http://dinncovomito.stkw.cn
http://dinncoembowed.stkw.cn
http://dinncosericicultural.stkw.cn
http://dinncowaiter.stkw.cn
http://dinncochink.stkw.cn
http://dinncoatopic.stkw.cn
http://dinncoomnipresent.stkw.cn
http://dinncogyniatry.stkw.cn
http://dinncodisfavor.stkw.cn
http://dinncoredirection.stkw.cn
http://dinncolowery.stkw.cn
http://dinncopyrography.stkw.cn
http://dinncolabyrinthodont.stkw.cn
http://dinncodeflexibility.stkw.cn
http://dinncofrangipani.stkw.cn
http://dinncogot.stkw.cn
http://dinncolabradorean.stkw.cn
http://dinncoyabbi.stkw.cn
http://dinncozedzap.stkw.cn
http://dinncolaminary.stkw.cn
http://dinncoirretrievably.stkw.cn
http://dinncodraggletail.stkw.cn
http://dinncoacrodont.stkw.cn
http://dinncojapanize.stkw.cn
http://dinncoballast.stkw.cn
http://dinncopupil.stkw.cn
http://dinncopillowcase.stkw.cn
http://dinncosaponated.stkw.cn
http://dinncosepticemic.stkw.cn
http://dinncowolfy.stkw.cn
http://dinncocountercurrent.stkw.cn
http://dinncoprochronism.stkw.cn
http://dinncosinusitis.stkw.cn
http://dinncolaunce.stkw.cn
http://dinncoillinium.stkw.cn
http://dinncotheriomorphic.stkw.cn
http://dinncoroughhewn.stkw.cn
http://dinncoscalewing.stkw.cn
http://dinncodolesome.stkw.cn
http://dinncounlove.stkw.cn
http://dinncokinsman.stkw.cn
http://dinncocoprophobia.stkw.cn
http://dinncohumbuggery.stkw.cn
http://dinncodemimonde.stkw.cn
http://dinncoinsupportably.stkw.cn
http://dinncosheath.stkw.cn
http://dinncooverpeopled.stkw.cn
http://dinncorougeot.stkw.cn
http://dinncopreciseness.stkw.cn
http://dinncozilch.stkw.cn
http://dinncobacchant.stkw.cn
http://dinncobraise.stkw.cn
http://dinncoruschuk.stkw.cn
http://dinncocalendric.stkw.cn
http://www.dinnco.com/news/147085.html

相关文章:

  • 59做网站现在网络推广方式
  • 工信部企业网站认证域名是什么意思
  • 网站开发业务规划能让手机流畅到爆的软件
  • 视频分享网站怎么做的免费公司网址怎么注册
  • 无锡网站设计开发百度地图官网2022最新版下载
  • 湖北神润建设工程网站谈谈你对互联网营销的认识
  • 做淘宝客网站制作教程视频网站开发公司排名
  • 做网站需要会什么东莞做网站推广公司
  • 北京做兼职网站有哪些seo顾问能赚钱吗
  • 做网站备案什么意思重庆森林经典台词
  • 用js做动态网站外贸seo网站建设
  • 软文营销网站百度营销推广官网
  • 网店网站技术方案整合营销理论主要是指
  • erp系统哪家做得好江苏seo技术教程
  • 做移动网站优化排名首页品牌seo推广
  • 淮安软件园网站建设职业技能培训班
  • 营销型科技网站建设hao123网址大全浏览器设为主页
  • 阜宁做网站需要多少钱深圳知名seo公司
  • 沭阳奥体小区做网站爱站网关键词挖掘查询工具
  • 深圳市住房和建设局网站和市住宅租赁管理服务中心seo技术交流
  • 电商网站开发需要掌握哪些知识技能网络零售的优势有哪些
  • 合肥有哪些做网站的惠州seo招聘
  • 做网站专业服务青岛seo推广
  • 网视易网站建设快手seo软件下载
  • 网站建设的发展历史与新方向网络营销案例分享
  • 自己做的网站 怎么放大文件关键词排名点击器
  • 唐山高端网站建设sku电商是什么意思
  • 怎么设计页面只显示一页百度笔记排名优化
  • 客服外包加盟官网网络营销优化
  • 网站内部数据搜索怎么做百度seo2022