我的收藏主界面

package com.huawei.myfavorite;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;

public class MainActivity extends Activity implements OnItemClickListener {

GridView mGridView;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initUI();



}

private void initUI() {
mGridView = (GridView) findViewById(R.id.myGrid);
SimpleAdapter sa = new SimpleAdapter(this, getData(),
R.layout.grid_unit, new String[] { "logo", "text" }, new int[] {
R.id.ivLogo, R.id.tvName });
mGridView.setAdapter(sa);
mGridView.setOnItemClickListener(this);
}

private List<Map<String, Object>> getData() {
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();

map.put("logo", R.drawable.list);
map.put("text", getResources().getString(R.string.text_toolKit));
data.add(map);

map = new HashMap<String, Object>();
map.put("logo", R.drawable.mp3file);
map.put("text", getResources().getString(R.string.text_ring));
data.add(map);

map = new HashMap<String, Object>();
map.put("logo", R.drawable.vediofile);
map.put("text", getResources().getString(R.string.text_video));
data.add(map);

map = new HashMap<String, Object>();
map.put("logo", R.drawable.imgfile);
map.put("text", getResources().getString(R.string.text_pic));
data.add(map);

map = new HashMap<String, Object>();
map.put("logo", R.drawable.pdffile);
map.put("text", getResources().getString(R.string.text_photo));
data.add(map);


map = new HashMap<String, Object>();
map.put("logo", R.drawable.folder_file);
map.put("text", getResources().getString(R.string.text_other));
data.add(map);





return data;
}

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

Intent mIntent = new Intent(this,FileListActivity.class);


switch(arg2){
case 0:mIntent.putExtra("type", CommonFiled.TYPE_TOOL);
mIntent.setClass(this,BoxActivity.class);
break;
case 1:mIntent.putExtra("type", CommonFiled.TYPE_RING);
break;
case 2:mIntent.putExtra("type", CommonFiled.TYPE_VIDEO);
break;
case 3:mIntent.putExtra("type", CommonFiled.TYPE_PICTURE);
break;
case 4:mIntent.putExtra("type", CommonFiled.TYPE_PHOTO);
break;
case 5:mIntent.putExtra("type", CommonFiled.TYPE_OTHER);
break;


}


startActivity(mIntent);

}

public boolean onSearchRequested() {
startActivity(new Intent(this,SearchableActivity.class));
return super.onSearchRequested();
}




}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值