共 26 篇文章 |
|
public void setContentView(int layoutResID) { getWindow().setContentView(layoutResID);void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs, boolean finishInflate) throws XmlPullParserException, IOException { final int depth = parser.getDepth();public static LayoutInflater from(Context context) { L... 阅16 转0 评0 公众公开 17-05-25 16:35 |
Android中Activity.this,getApplicationContext(),getBaseContext()和this详解。Activity.this的context属于Activity,生命周期与Activity相同,随着当前的Activity.this消亡而消亡。根据你的控件的生命周期决定传Activity.this还是getApplicationContext(),如果你的控件的生命周期是整个应用,就传送getApplicationContext(),如果是当前的Ac... 阅117 转0 评0 公众公开 17-04-28 13:24 |
Toast默认的有两个LENGTH_LONG(长)和LENGTH_SHORT(短),也可以使用毫秒如2000ms Toast toast=Toast.makeText(getApplicationContext(), "默认的Toast", Toast.LENGTH_SHORT); //显示toast信息 toast.show();Java代码 Toast toast=Toast.makeText(getApplicationContext(), "自定义显示位置的Toast", Toast.LENGTH_SHOR... 阅41 转0 评0 公众公开 17-04-15 14:36 |
Android开发中Handler的经典总结请选中您要保存的内容,粘贴到此文本框。这个时候,Handler就出现了。,来解决这个复杂的问题 ,由于Handler运行在主线程中(UI线程中), 它与子线程可以通过Message对象来传递数据, 这个时候,Handler就承担着接受子线程传过来的(子线程用sedMessage()方法传弟)Message对象,(里面包含数据) , 把这些消息放... 阅3 转0 评0 公众公开 17-04-15 14:20 |
说起Handler,就不得不提Message、MessageQueue以及Looper。//获取Message实例的方式Message msg1 = Message.obtain();//或Message msg2 = Handler.obtainMessage();线程默认没有Looper,在创建Handler对象前,我们需要为线程创建Looper。使用Looper.prepare()方法创建Looper,使用Looper.loop()方法运行消息队列。mHandler = new Handler() { p... 阅34 转0 评0 公众公开 17-04-15 14:19 |
setContentView剖析1、setContentView的作用是将View加载到根view之上,这样当显示view时,先显示根view,然后在显示子view,以此类推,最终将所有view显示出来。1)使用LayoutInflater inflate两个view:v1,v22)使用setContentView(View view)方法设置这两个view具体讲解在http://blog.csdn.net/yanzi1225627/article/details/7802402. 阅699 转1 评0 公众公开 17-04-15 14:12 |
【Android进阶】android:configChanges属性总结android中的组件Activity在manifest.xml文件中可以指定参数android:ConfigChanges,用于捕获手机状态的改变。对android:configChanges属性,一般认为有以下几点:1、不设置Activity的android:configChanges时,切屏会重新调用各个生命周期,切横屏时会执行一次,切竖屏时会执行两次。解决方法:A... 阅8 转0 评0 公众公开 17-04-15 14:08 |
android:screenOrientation属性在开发android的应用中,有时候需要限制横竖屏切换。只需要在AndroidManifest.xml文件中加入android:screenOrientation属性限制。android:screenOrientation="landscape"是限制此页面横屏显示, android:screenOrientation="portrait"是限制此页面数竖屏显示。"sensor"- 根據物... 阅25 转0 评0 公众公开 17-04-15 14:05 |
1 button1.setOnClickListener(new OnClickListener() { 2 @Override 3 public void onClick(View v) { 4 //启动另一个Activity,(通过action属性进行查找) 5 Intent intent = new Intent(); 6 //设置动作(实际action属性就是一个字符串标记而已) 7 intent.setAction("com.example.smyh006intent01.MY_ACTION"); //方法:Inte... 阅74 转0 评0 公众公开 17-04-14 21:21 |
import android.app.> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+... 阅15 转0 评0 公众公开 17-04-14 13:25 |