- 浏览: 26494 次
最新评论
文章列表
主页面布局:layout/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:id=&qu ...
14章类型信息-之类型转换前先做检查--之使用类字面常量--类名.class--以及动态instanceof(isInstance方法)----递归计数(计算各个类的个数)
- 博客分类:
- java编程思想
实例代码:
实体类父类:
//: typeinfo/pets/Individual.javapackage typeinfo.pets;public class Individual implements Comparable<Individual> {private static long counter = 0;private final long id = counter++;private String name;public Individual(String name) { this.name = name; }// 'name' is optional:publi ...
instanceof用法:
对于instanceof有比较严格的限制,只可将其与命名类型进行比较,而不能与class对象做比较。
理解:这里所说的就是像if(pet instanceof Mutt)counter.count("Mutt");这里的Mutt,不能用对象比较,只能用类名,比如(Mutt mutt = new Mutt()然后用mutt)或者 Mutt.class就不行了,
实例代码:
实体类父类:
//: typeinfo/pets/Individual.javapackage typeinfo.pets;public class Individua ...
说明:(之前只用handle是因为主线程默认就加上Looper.prepare()和Looper.loop()的。所以主线程可以通过handle收发信息,但是如果在thread里面的话,就是工作线程,工作线程的话,默认是没有加上那两段代码的,所以要手动加上,然后再通过handle.sendMessage()发送信息到工作线程才能取到信息)
主显示布局以及代码:
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns: ...
线程通信之handle用法
- 博客分类:
- android
主显示布局以及代码:
activity_main.xml:
<LinearLayout 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:orientation="verti ...
android之listView之增删改查
- 博客分类:
- android
主显示布局以及代码:
activity_main.xml:
<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"><ListViewandroid:id="@ ...
android之listView缓存机制
- 博客分类:
- android
activity_main.xml:
<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:paddingBottom="@dimen/activity_ve ...
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><Buttonandroid:id="@+id/btnStandardDialog"and ...
GridView:
/activity_main.xml
<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"><GridViewandroid:id="@+ ...
listView页面布局:layout/activity_main.xml:
<LinearLayout 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:orientation="ve ...
android之ArrayAdaper应用
- 博客分类:
- android
listView页面布局:layout/activity_main.xml:
<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:paddingBottom=&quo ...
listView页面布局:layout/activity_main.xml:
<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:paddingBottom=&quo ...
listView页面布局:layout/activity_main.xml:
<LinearLayout 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:orientation="ho ...
android之启动桌面activity
- 博客分类:
- android
主页面布局:layout\activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><Buttonandroid:id="@+id/btnHome"a ...
主页面布局:layout/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><Buttonandroid:id="@+id/btn1"androi ...