




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
【移動應用開發技術】AndroidUI新組件怎么用
MaterialDialog/upload/information/20200623/125/123863.pngprivate
void
showDialog1()
{
android.support.v7.app.AlertDialog.Builder
builder
=
new
AlertDialog.Builder(this);
builder.setMessage("讓我們一起飛,我帶著你,你帶著錢,來一場說走就走的旅行")
.setNegativeButton("取消",
null)
.setPositiveButton("確定",
null)
.setTitle("Material
Design
Dialog")
.show();
}SwipeRefreshLayout/upload/information/20200623/125/123864.gif<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="/apk/res/android"
xmlns:app="/apk/res-auto"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--可滑動的組件,比如ScrollView,ListView,GridView,等-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--添加自己的內容-->
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>swipeRefreshLayout
=
findView(R.id.swipe_container);
//設置下拉刷新監聽事件
swipeRefreshLayout.setOnRefreshListener(this);
//設置進度條的顏色
swipeRefreshLayout.setColorSchemeColors(Color.RED,
Color.BLUE,
Color.GREEN);
//設置圓形進度條大小
swipeRefreshLayout.setSize(SwipeRefreshLayout.LARGE);
//設置進度條背景顏色
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(Color.DKGRAY);
//設置下拉多少距離之后開始刷新數據
swipeRefreshLayout.setDistanceToTriggerSync(50);LinearLayoutCompat
/upload/information/20200623/125/123865.png<android.support.v7.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal"
android:orientation="vertical"
app:divider="@drawable/line"
app:dividerPadding="25dp"
app:showDividers="middle|beginning|end">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="CSDN
廢墟的樹"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="CSDN
廢墟的樹"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="CSDN
廢墟的樹"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="CSDN
廢墟的樹"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="CSDN
廢墟的樹"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="CSDN
廢墟的樹"
android:textSize="20sp"
android:textStyle="bold"
/>
</android.support.v7.widget.LinearLayoutCompat><?xml
version="1.0"
encoding="utf-8"?>
<shape
xmlns:android="/apk/res/android">
<solid
android:color="@color/material_blue_grey_800"
/>
<!--需要設置高度,否則不顯示-->
<size
android:height="1px"
/>
</shape>ListPopupWindow
/upload/information/20200623/125/123866.pngpublic
void
showListPopup(View
view)
{
String
items[]
=
{"item1",
"item2",
"item3",
"item4",
"item5"};
final
ListPopupWindow
listPopupWindow
=
new
ListPopupWindow(this);
//設置ListView類型的適配器
listPopupWindow.setAdapter(new
ArrayAdapter<String>(SwipeRefreshActivity.this,
android.R.layout.simple_list_item_1,
items));
//給每個item設置監聽事件
listPopupWindow.setOnItemClickListener(new
AdapterView.OnItemClickListener()
{
@Override
public
void
onItemClick(AdapterView<?>
parent,
View
view,
int
position,
long
id)
{
Toast.makeText(SwipeRefreshActivity.this,
"the
position
is"
+
position,
Toast.LENGTH_SHORT).show();
//
listPopupWindow.dismiss();
}
});
//設置ListPopupWindow的錨點,也就是彈出框的位置是相對當前參數View的位置來顯示,
listPopupWindow.setAnchorView(view);
//ListPopupWindow
距錨點的距離,也就是相對錨點View的位置
listPopupWindow.setHorizontalOffset(100);
listPopupWindow.setVerticalOffset(100);
//設置對話框的寬高
listPopupWindow.setWidth(300);
listPopupWindow.setHeight(600);
listPopupWindow.setModal(false);
listPopupWindow.show();
}PopupMenu/upload/information/20200623/125/123867.pngpublic
void
showPopupMenu(View
view)
{
//參數View
是設置當前菜單顯示的相對于View組件位置,具體位置系統會處理
PopupMenu
popupMenu
=
new
PopupMenu(this,
view);
//加載menu布局
popupMenu.getMenuInflater().inflate(R.menu.menu_main,
popupMenu.getMenu());
//設置menu中的item點擊事件
popupMenu.setOnMenuItemClickListener(new
PopupMenu.OnMenuItemClickListener()
{
@Override
public
boolean
onMenuItemClick(MenuItem
item)
{
return
false;
}
});
//設置popupWindow消失的點擊事件
popupMenu.setOnDismissListener(new
PopupMenu.OnDismissListener()
{
@
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025租房合同范本(完美打印版)
- 2025共同租賃商業物業合同模板
- 農產品倉儲與農業供給側改革考核試卷
- 《2025勞務合同聘用離職人員協議》
- 洗滌機械的數字化營銷策略考核試卷
- 2025年雞肉采購銷售合同范本
- 2025辦公室租賃合同模板()
- 2025新簽訂勞動合同模板示例
- 2025年學生會公關部廣告投放合同
- 瑜伽老師簽約合同協議
- 訂餐協議合同協議
- 房屋征拆合同協議
- 湖北省武漢市2025屆高中畢業生四月調研考試數學試卷及答案(武漢四調)
- Unit 1 Growing up (Period 1)(教學設計)-2024-2025學年滬教牛津版(深圳用)英語六年級上冊
- 2025年水務行業化學檢驗員職業技能競賽參考試題(附答案)
- 創新創業實戰學習通超星期末考試答案章節答案2024年
- GB 21258-2024燃煤發電機組單位產品能源消耗限額
- DB34∕T 4010-2021 水利工程外觀質量評定規程
- 醫療美容診所規章制度上墻
- 人教鄂教版五年級科學下期中測試卷(1-9課)(含答案)
- 普通高等學校軍事理論教程
評論
0/150
提交評論