南昌航空大学android期末复习资料之编程题Word下载.docx
- 文档编号:17848747
- 上传时间:2022-12-11
- 格式:DOCX
- 页数:27
- 大小:118.31KB
南昌航空大学android期末复习资料之编程题Word下载.docx
《南昌航空大学android期末复习资料之编程题Word下载.docx》由会员分享,可在线阅读,更多相关《南昌航空大学android期末复习资料之编程题Word下载.docx(27页珍藏版)》请在冰豆网上搜索。
<
LinearLayout
android:
wrap_content"
horizontal"
>
<
TextView
id="
@+id/NameText"
text="
姓名:
"
/>
<
EditText
android:
@+id/Name"
king"
/LinearLayout>
@+id/AgeText"
年龄:
@+id/UserText"
30"
@+id/HeightText"
身高:
@+id/Height"
1.75"
Button
@+id/Button1"
添加数据"
@+id/Button2"
全部显示"
@+id/Button3"
清除显示"
@+id/Button4"
全部删除"
相对布局
RelativeLayoutxmlns:
@string/nametext"
layout_marginTop="
10dip"
layout_toRightOf="
@id/NameText"
@string/agetext"
30dip"
layout_below="
@+id/Age"
@id/Name"
@id/AgeText"
@string/edittext2"
@string/heighttext"
@id/Age"
@id/HeightText"
@string/edittext3"
@id/Height"
@string/buttontext1"
@id/Button1"
@string/buttontext2"
@id/Button2"
@string/buttontext3"
@id/Button3"
@string/buttontext4"
/RelativeLayout>
String.xml
resources>
stringname="
nametext"
/string>
agetext"
heighttext"
buttontext1"
添加数据<
buttontext2"
全部显示<
buttontext3"
清除显示<
buttontext4"
全部清除<
edittext1"
king<
edittext2"
30<
edittext3"
1.75<
app_name"
RelativeLayout<
/resources>
绝对布局
AbsoluteLayoutxmlns:
layout_y="
280dip"
50dip"
layout_x="
40dip"
60dip"
110dip"
100dip"
160dip"
80dip"
240dip"
/AbsoluteLayout>
如果在这个基础上加上TabHost组件,如下图
TabDemo.java
publicclassTabDemoextendsTabActivity{
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
TabHosttabHost=getTabHost();
LayoutInflater.from(this).inflate(R.layout.tab1,tabHost.getTabContentView(),true);
LayoutInflater.from(this).inflate(R.layout.tab2,tabHost.getTabContentView(),true);
LayoutInflater.from(this).inflate(R.layout.tab3,tabHost.getTabContentView(),true);
tabHost.addTab(tabHost.newTabSpec("
TAB1"
).
setIndicator("
线性布局"
).setContent(R.id.layout01));
TAB2"
绝对布局"
).setContent(R.id.layout02));
TAB3"
相对布局"
).setContent(R.id.layout03));
}
}
上面是java文件代码,这样还不行,要建立三个xml文件,分别为tab1.xml,tab2.xml,tab3.mxl,也就是上面三种布局的xml文件,不过要在每个xml文件的开头分别加上android:
id="
@+id/layout01"
,android:
@+id/layout02"
@+id/layout03"
如:
tab1.xml(线性)
android:
ListView的使用
Main.xml
TextViewandroid:
@+id/TextView01"
@string/hello"
/>
ListViewandroid:
@+id/ListView01"
/ListView>
ListViewDemo.java
publicclassListViewDemoextendsActivity{
/**Calledwhentheactivityisfirstcreated.*/
@Override
setContentView(R.layout.main);
finalTextViewtextView=(TextView)findViewById(R.id.TextView01);
ListViewlistView=(ListView)findViewById(R.id.ListView01);
List<
String>
list=newArrayList<
();
list.add("
ListView子项1"
);
ListView子项2"
ListView子项3"
ArrayAdapter<
adapter=newArrayAdapter<
(this,
android.R.layout.simple_list_item_1,list);
listView.setAdapter(adapter);
AdapterView.OnItemClickListenerlistViewListener=newAdapterView.OnItemClickListener(){
@Override
publicvoidonItemClick(AdapterView<
arg0,Viewarg1,intarg2,longarg3){
Stringmsg="
父View:
+arg0.toString()+"
\n
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 南昌 航空 大学 android 期末 复习资料 编程
![提示](https://static.bdocx.com/images/bang_tan.gif)