<TextView android:id="@+id/name_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textSize="sp" android:textColor="#beea" android:text="My name is ZeluLi"/>
TextView myTextView = (TextView) findViewById(R.id.name_text_view); String myText = myTextView.getText().toString(); myTextView.setText(myText+" Add");
<Button android:id="@+id/click_button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="点我"/>
Button button = (Button) findViewById(R.id.click_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//点击按钮要做的事情
}
});
button.setOnClickListener(this);
//重写委托回调的方法
/**
* Called when a view has been clicked.
*
* @param v The view that was clicked.
*/
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.click_button:
//点击按钮后要做的事情
break;
default:
break;
}
}
<EditText android:id="@+id/edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="placeHoder: type something here" android:maxLines=""/>
EditText myEditText = (EditText) findViewById(R.id.edit_text); String inputText = myEditText.getText().toString(); Toast.makeText(MainActivity.this, inputText, Toast.LENGTH_SHORT).show();
AlertDialog.Builder alterDialog = new AlertDialog.Builder(MainActivity.this);
alterDialog.setTitle("提示框");
alterDialog.setMessage("提示内容");
alterDialog.setCancelable(false);
alterDialog.setPositiveButton("好的", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "好的", Toast.LENGTH_SHORT).show();
}
});
alterDialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "取消", Toast.LENGTH_SHORT).show();
}
});
alterDialog.show();
<ProgressBar android:id="@+id/my_progress_bar" android:layout_width="match_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" android:max=""/>
ProgressBar myProgressBar = (ProgressBar) findViewById(R.id.my_progress_bar);
myProgressBar.setProgress(myProgressBar.getProgress()+);
if (myProgressBar.getProgress() == myProgressBar.getMax()) {
myProgressBar.setVisibility(View.GONE);
myProgressBar.setProgress();
} else {
myProgressBar.setVisibility(View.VISIBLE);
}
/**
* Called when a view has been clicked.
*
* @param v The view that was clicked.
*/
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.click_button:
ProgressDialog myProgressDialog = new ProgressDialog(MainActivity.this);
myProgressDialog.setTitle("ProgressDialog");
myProgressDialog.setMessage("Loading……");
myProgressDialog.setCancelable(true);
myProgressDialog.show();
break;
default:
break;
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.lizelu.userinterfacedemo.MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!--垂直线性布局方式--> <LinearLayout android:layout_width="pt" android:layout_height="match_parent" android:background="#ff" android:orientation="vertical"> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="pt" android:background="#ff" android:orientation="horizontal"> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff" android:orientation="horizontal"> </LinearLayout> </LinearLayout> </LinearLayout> </RelativeLayout>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:text="aa"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="bb"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="cc" android:layout_gravity="right"/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top" android:text="aa"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bb" android:layout_gravity="center" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:text="cc"/>
<Button android:layout_width="pt" android:layout_height="wrap_content" android:layout_weight="" android:text="你好"/> <Button android:layout_width="pt" android:layout_height="wrap_content" android:layout_weight="" android:text="Android"/> <Button android:layout_width="pt" android:layout_height="wrap_content" android:layout_weight="" android:text="iOS"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.lizelu.userinterfacedemo.MainActivity"> <Button android:id="@+id/button_center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="center"/> <Button android:id="@+id/button_above" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/button_center" android:layout_centerInParent="true" android:text="above"/> <Button android:id="@+id/button_below" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button_center" android:layout_centerInParent="true" android:text="below"/> <Button android:id="@+id/button_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@+id/button_center" android:layout_centerVertical="true" android:text="left"/> <Button android:id="@+id/button_right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/button_center" android:layout_centerVertical="true" android:text="right"/> </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.lizelu.userinterfacedemo.MainActivity"> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ff"> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ff"> </FrameLayout> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ff"> </FrameLayout> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ffff"> </FrameLayout> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#"> </FrameLayout> </FrameLayout> </RelativeLayout>
<TableLayout android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns=""> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="用户名:"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入用户名"/> </TableRow> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密 码:"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入密码" android:inputType="textPassword"/> </TableRow> <TableRow> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="登录" android:layout_span=""/> </TableRow> </TableLayout>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有