码迷,mamicode.com
首页 > Web开发 > 详细

WebView

时间:2016-08-26 18:05:31      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

源码

 

public class MainActivity extends AppCompatActivity {
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//条目
final Map<String,Class> activities = new LinkedHashMap<String,Class>();
activities.put("WebView", WebViewActivity.class);
//ListView
ListView listView = (ListView)this.findViewById(R.id.listView);
final String[] keies_Title = activities.keySet().toArray(new String[activities.size()]);
ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_expandable_list_item_1,keies_Title);//新建适配器对象
listView.setAdapter(arrayAdapter);//适配
//事件
listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){//点击事件
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(context,activities.get(keies_Title[position]));
startActivity(intent);
}
});
}
}

布局文件
<?xml version="1.0" encoding="utf-8"?>
<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_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.cz.czapp.MainActivity">

<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView">
</ListView>
</RelativeLayout>

权限

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
 

 

WebView

标签:

原文地址:http://www.cnblogs.com/cz2012/p/5811301.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!