編輯:關於android開發
1.xml
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
</FrameLayout>
fargment_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list"></ListView>
</LinearLayout>
list_item_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp" >
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TEXT1"
android:textSize="16sp" />
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/text1"
android:layout_below="@+id/text1"
android:text="TEXT2"
android:textSize="12sp" />
</RelativeLayout>
2.java
MainActivity.java
public class MainActivity extends FragmentActivity {
MapView mMapView = null;
private BaiduMap mBaiduMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//在使用SDK各組件之前初始化context信息,傳入ApplicationContext
//注意該方法要再setContentView方法之前實現
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
}
}
public static class PlaceholderFragment extends Fragment implements AdapterView.OnItemClickListener {
private ListView listView;
private MainAdapter adapter;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
listView= (ListView) view.findViewById(R.id.list);
adapter = new MainAdapter(getContext(),R.layout.list_item_main,getDateBean());
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
return view;
}
public static List<DataBean> getDateBean() {
List<DataBean> list = new ArrayList<>();
list.add(new DataBean("基本地圖功能", "創建一張百度地圖並管理地圖的生命周期"));
list.add(new DataBean("圖層展示", "展示普通圖、衛星圖、交通流量圖及百度城市熱力圖"));
list.add(new DataBean("地圖操作功能", "介紹地圖基本控制方法"));
return list;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent;
switch (position) {
case 0:
intent = new Intent(getActivity(), BaseMap.class);
startActivity(intent);
break;
case 1:
intent = new Intent(getActivity(), Layers.class);
startActivity(intent);
break;
case 2:
intent = new Intent(getActivity(), Location.class);
startActivity(intent);
break;
default:
break;
}
}
}
public static class MainAdapter extends ArrayAdapter<DataBean> {
private int resourceID;
public MainAdapter(Context context, int resource, List<DataBean> objects) {
super(context, resource, objects);
resourceID = resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = View.inflate(getContext(), resourceID, null);
holder = new ViewHolder();
holder.text1 = (TextView) convertView.findViewById(R.id.text1);
holder.text2 = (TextView) convertView.findViewById(R.id.text2);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
DataBean dataBean = getItem(position);
holder.text1.setText(dataBean.text1);
holder.text2.setText(dataBean.text2);
return convertView;
}
class ViewHolder{
TextView text1;
TextView text2;
}
}
public static class DataBean {
String text1;
String text2;
public DataBean(String text1, String text2) {
this.text1 = text1;
this.text2 = text2;
}
}
}
仿哔哩哔哩應用客戶端Android版源碼,android這是一款高仿哔哩哔哩安卓客戶端,跟官方網的差不多吧,界面也幾乎是一樣的,應用裡面也加了一些彈出廣告,大家可以參考一
Android筆記——Android中數據的存儲方式(三),android筆記 Android系統集成了一個輕量級的數據庫:SQLite,所以Android對數據庫的支
Android與JS之間跨平台異步調用,androidjs異步 為什麼突然要搞這個問題呢? 在開發浏覽器的時候遇到這個狗血的問題,花了將近1天的
Gui系統之View體系(2)---View的setContent,---viewsetcontent1.從SetContentView講起 1.1Activty的set