发布于 2016-04-12 08:55:46 | 155 次阅读 | 评论: 0 | 来源: 网友投递
Android移动端操作系统
Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。
<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" >
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
android:id="@+id/btn"
android:background="@drawable/sl_btn_red" />
</RelativeLayout>
private TextView btnClose = null;
private TextView btnAgree = null;
private TextView btnDisagree = null;
private WebView mWebView = null;
public MyDialog(Context context) {
super(context, R.style.item_tnc_dialog);
setCancelable(false); // 阻止返回键的响应
setContentView(R.layout.dialog_view);
getWindow().setLayout(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
setUpView();
}
private void setUpView() {
mWebView = (WebView) findViewById(R.id.item_tnc_dialog_webview);
btnClose = (TextView) findViewById(R.id.item_tnc_dialog_close);
btnAgree = (TextView) findViewById(R.id.item_tnc_dialog_agree);
btnDisagree = (TextView) findViewById(R.id.item_tnc_dialog_disagree);
btnClose.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dismiss();
}
});
btnDisagree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
System.exit(0);
}
});
btnAgree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "YOU SELECTED AGREE",
Toast.LENGTH_SHORT).show();
dismiss();
}
});
showDialog();
}
/** 加载webview的内容 */
public void showDialog() {
String localHtml = "file:///android_asset/los.html";
if (mWebView != null) {
mWebView.getSettings().setDefaultTextEncodingName("utf-8");
mWebView.loadUrl(localHtml);
}
buttonsDisplayTwo(false);
}
/** 当true的时候,出现同意和不同意两个选项,反之是关闭选项 */
private void buttonsDisplayTwo(boolean two) {
btnAgree.setVisibility(two ? View.VISIBLE : View.GONE);
btnDisagree.setVisibility(two ? View.VISIBLE : View.GONE);
btnClose.setVisibility(two ? View.GONE : View.VISIBLE);
}
private TextView btnClose = null;
private TextView btnAgree = null;
private TextView btnDisagree = null;
private WebView mWebView = null;
public MyDialog(Context context) {
super(context, R.style.item_tnc_dialog);
setCancelable(false); // 阻止返回键的响应
setContentView(R.layout.dialog_view);
getWindow().setLayout(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
setUpView();
}
private void setUpView() {
mWebView = (WebView) findViewById(R.id.item_tnc_dialog_webview);
btnClose = (TextView) findViewById(R.id.item_tnc_dialog_close);
btnAgree = (TextView) findViewById(R.id.item_tnc_dialog_agree);
btnDisagree = (TextView) findViewById(R.id.item_tnc_dialog_disagree);
btnClose.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dismiss();
}
});
btnDisagree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
System.exit(0);
}
});
btnAgree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "YOU SELECTED AGREE",
Toast.LENGTH_SHORT).show();
dismiss();
}
});
showDialog();
}
/** 加载webview的内容 */
public void showDialog() {
String localHtml = "file:///android_asset/los.html";
if (mWebView != null) {
mWebView.getSettings().setDefaultTextEncodingName("utf-8");
mWebView.loadUrl(localHtml);
}
buttonsDisplayTwo(false);
}
/** 当true的时候,出现同意和不同意两个选项,反之是关闭选项 */
private void buttonsDisplayTwo(boolean two) {
btnAgree.setVisibility(two ? View.VISIBLE : View.GONE);
btnDisagree.setVisibility(two ? View.VISIBLE : View.GONE);
btnClose.setVisibility(two ? View.GONE : View.VISIBLE);
}