重温5 UI开发

public class

TextView

extends View

implements ViewTreeObserver.OnPreDrawListener
java.lang.Object
   ↳android.view.View
    ↳android.widget.TextView
Known Direct Subclasses
ButtonRepresents a push-button widget. 
CheckedTextViewAn extension to TextView that supports the Checkable interface. 
ChronometerClass that implements a simple timer. 
DigitalClockThis class was deprecated in API level 17. It is recommended you useTextClock instead. 
EditTextEditText is a thin veneer over TextView that configures itself to be editable. 
TextClock

TextClock can display the current date and/or time as a formatted string. 

Known Indirect Subclasses
1、fill_parent与match_parent
Android2.2开始两者相同,2.2之前用fill_parent,官方推荐match_parent。
2、layout_gravity与gravity
2.1)gravity:指定控件中文字的对齐方式。
layout_gravity:指定控件在所在布局中的对齐方式。
LinearLayout中:
orientation:vertical时:layout_gravity水平方向的设置有效:left/right/center_horizontal
orientation:horiaontal时:layout_gravity垂直方向设置有效:top/bottom/center_vertical.  center 都可以用,总有一个方向生效
2.2)想要设置某个控件居底,可以在空间外加一层LinearLayout并设置其gravity为bottom.
<LinearLayout
...
android:gravity="bottom"
...><Button
....../>
</LinearLayout>
3、Button点击事件
3.1)XML: 
<Button
...
android:onClick="onClick"/><!--点击事件的方法名-->

public void onClick(View view){
}
3.2) 
 login_btn.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View view){}}});//匿名类的方式
3.3)
public class MainActivity extends Activity implements onClickListener{@Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);Button button = (Button)findViewById(R.id.button);button.setOnClickListener(this);
}@Overridepublic void onClick(View view){
}
}
3.4)
  Button Btn = (Button) findViewById(R.id.button);  Btn2.setOnClickListener(listener);//设置监听    }  Button.OnClickListener listener = new Button.OnClickListener(){//创建监听对象    public void onClick(View v){    }    };  
4、EditText
当需要输入EditText中的内容过多时,可以指定最大行数,当达到最大行数时文本就会往上滚动。
android:maxLines="2"
5、ProgressBar/AlertDialog/ProgressDialog
 <ProgressBarandroid:id="@+id/progressBar"android:layout_width="wrap_content"android:layout_height="wrap_content"/><!-- 可以设置style="?android:attr/progressBarStyleHorizontal"android:max="100"-->
//AlertDialog/ProgressDialog
@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();switch(id){case R.id.alertDialog:AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);alertDialog.setTitle("Warning");alertDialog.setMessage("This is a warning");alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}});alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}});alertDialog.show();break;case R.id.progressDialog:ProgressDialog progressDialog = new ProgressDialog(this);progressDialog.setTitle("ProgressDialog");progressDialog.setMessage("loading...");progressDialog.show();break;default:}return super.onOptionsItemSelected(item);}





完整代码在:https://github.com/HiSunny/ComeOnProgressBarAlertDialogProgressDialog.git

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/348746.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JWT令牌的秘密轮换

当您使用JSON Web令牌 &#xff08; JWT &#xff09;或需要对有效载荷信息进行签名或加密的任何其他令牌技术时&#xff0c;设置令牌的到期日期很重要&#xff0c;因此&#xff0c;如果令牌到期&#xff0c;则可以假定这可能被视为安全漏洞&#xff0c;您拒绝使用此令牌进行任…

重温6 ListView相关|单位dp/sp

dp:密度无关像素。 sp&#xff1a;可伸缩像素。解决文字大小适配问题。 密度&#xff1a;Android中的密度即屏幕每英寸所包含的像素数&#xff0c;通常以dpi为单位&#xff0c;例如一个宽2英寸长3英寸手机屏幕&#xff0c;若分辨率为320*480&#xff0c;则屏幕密度为320dpi。…

重温7 布局相关

1、LinearLayout 可以在控件中使用&#xff1a; android:layout_weight"1" android:layout_width"0dp"设置控件占屏幕宽度&#xff0c;上表示占屏幕1/2。 2、TableLayout <TableLayout android:stretchColums"1" ...>上指定为1表示拉伸第…

wso2 esb_通过运行示例从WSO2 ESB开始

wso2 esb我最近加入了一个新任务&#xff0c;我们必须基于WSO2工具栈实施ESB解决方案。 尽管我熟悉ESB的大多数概念以及其他一些实现&#xff08;例如Mule ESB &#xff09;&#xff0c;但这是我第一次必须使用WSO2 ESB 。 幸运的是&#xff0c;有很多文档可以找到&#xff0c;…

Java SE中的Bootstrap CDI 2.0

抽象 这是在Java SE应用程序中引导CDI 2.0的快速参考。 CDI 2.0&#xff08;JSR 365&#xff09; Maven依赖 <dependency><groupId>org.jboss.weld.se</groupId><artifactId>weld-se-core</artifactId><version>3.0.2.Final</version…

持久化技术SharedPreferences存储

public interface SharedPreferences android.content.SharedPreferences Class Overview Interface for accessing and modifying preference data returned by getSharedPreferences(String, int). 1、调用SharedPreferences对象的edit()方法获得SharedPreferences.Editor对象…

Handler、Message的简单使用

Android没有全局的消息队列&#xff0c;Android的消息队列是和某个线程相关联在一起的。每个线程最多只有一个消息队列&#xff0c;消息的处理也是在这个线程中完成。也就是说&#xff0c;如果想在当前线程中使用消息模型&#xff0c;则必须构建一个消息队列&#xff0c;消息机…

我们相信加密! 教程

许多人认为加密是一个复杂的主题&#xff0c;这很难理解。 虽然可以实现它的某些方面&#xff0c;但是每个人都可以理解它在更高层次上的工作方式。 这就是我要处理的这篇文章。 用简单的术语解释它是如何工作的&#xff0c;然后使用一些代码。 是的&#xff0c;我们信任加密…

使用Http协议访问网络--HttpURLConnection

public abstract classHttpURLConnection extends URLConnectionjava.lang.Object ↳java.net.URLConnection ↳java.net.HttpURLConnection 1、获取HttpURLConnection实例Protected ConstructorsHttpURLConnection(URL url)Constructs a new HttpURLConnection instance …

Spring Cloud –基本设置

Spring Cloud解决了分布式系统的常见问题。 但是&#xff0c;对于只使用广为人知的整体应用程序工作的人来说&#xff0c;从一开始就跳入一长串为分布式服务设计的模式可能会让人不知所措。 本文将通过实用的方法为您介绍Spring Cloud的基础知识。 完成后&#xff0c;您不仅应该…

Eclipse中的Tomcat:6个流行的“如何做”问题

学习新技术总是一个艰难的过程。 当您尝试学习将要相互交互的两种技术时&#xff0c;此过程变得更加困难。 Tomcat和Eclipse是Java EE开发中最流行的先决条件之一。 因此&#xff0c;要成为一名专业的开发人员&#xff0c;您需要知道如何使用此对执行最需要的操作以及如何进行一…

Spring Boot中带有CKEditor的AJAX

1.概述 在本文中&#xff0c;我们将介绍如何在Spring Boot中使用CKEditor 。 在本教程中&#xff0c;我们将导入一个包含大量数据的XML文档&#xff0c;对使用GET请求将一组数据加载到CKEditor实例的能力进行编程&#xff0c;并执行POST请求以保存CKEditor的数据。 我们将使用…

使用Http协议访问网络--HttpClient

public interface HttpClient org.apache.http.client.HttpClient HttpClient是Apache提供的Http网络访问接口。1、创建HttpClient实例HttpClient是一个接口&#xff0c;无法直接创建实例&#xff0c;通常创建一个DefaultHttpClient&#xff08;HttpClient 的SubClass&#xff…

编写测试用例

1、创建测试用例 为ComeOnBroadcastReceiverDo创建一个测试用例&#xff1a; 在导航栏File-->New-->Other 选择AndroidTestProject 2、点击next输入测试工程的name&#xff0c;选择测试工程路径 点击next,选择要测试的工程&#xff1a; 点击Finish完成测试工程的新建 被…

欢迎界面动画

实现一个欢迎界面的动画&#xff0c;即打开app显示的页面&#xff0c;动画结束后跳到Activity。 1、欢迎界面的背景是一个绿色矩形 <?xml version"1.0" encoding"utf-8"?> <shape xmlns:android"http://schemas.android.com/apk/res/andr…

动画机制与使用

Android3.0之前有两种动画&#xff0c;一种方式是补间动画 Tween Animation、另一种叫逐帧动画 Frame Animation&#xff08;也称Drawable Animation &#xff09;Android3.0以后增加了属性动画 Property Animation。Tween Animation、Frame Animation只能用于View&#xff0c;…

1、HTTP--Web's foundation

1、1 HTTP(HyperText Transfer Protocol)超文本传输协议----Internet的多媒体信使 1、2 Web客户端和服务器 Web内容都是存储在Web服务器上的&#xff0c;Web服务器使用的是HTTP协议&#xff0c;因此常被成为HTTP服务器。HTTP服务器和HTTP客户端共同构成World Wide Web的基本组…

IP地址分类及ISO-OSI、三次握手

1. A类地址A类地址的表示范围为&#xff1a;0.0.0.0~126.255.255.255(00000000~01111110)&#xff0c;最前面一位是“0”&#xff0c;用7位&#xff08;bit&#xff09;来标识网络号&#xff0c;24位标识主机号&#xff1b;默认网络掩码为&#xff1a;255.0.0.0&#xff0c;111…

drools 决策表_骆驼和春天的Drools决策表

drools 决策表正如我在之前的文章中所展示的那样&#xff0c; JBoss Drools是一个非常有用的规则引擎 。 唯一的问题是&#xff0c;对于非技术人员而言&#xff0c;以Rule语言创建规则可能会非常复杂。 这就是为什么人们可以提供一种简便的方法来创建业务规则-在电子表格中创建…