-
android_gridview源代码 item.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" android:orientation="vertical" android:gravity="center" android:background="#000000" > <ImageView android:src="@drawable/ic_launcher" android:layout_width="60dp" android:layout_height="60dp" android:id="@+id/image"/> <TextView android:id="@+id/text" android:layout_marginTop="5dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="文字" android:textColor="#ffffff"/> </LinearLayout>查看全部
-
android_gridview源代码 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" android:orientation="vertical" > <GridView android:layout_marginTop="10dp" android:id="@+id/gridView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numColumns="3" android:horizontalSpacing="10dp" android:verticalSpacing="10dp" ></GridView> </LinearLayout>查看全部
-
android_gridview源代码 MainActivity.java续 dataList=new ArrayList<Map<String,Object>>(); //getdata(); adapter=new SimpleAdapter(this, getdata(), R.layout.item, new String[]{"image","text"}, new int[]{R.id.image,R.id.text} ); gridView.setAdapter(adapter); gridView.setOnItemClickListener(this); } private List<Map<String, Object>> getdata() { for(int i=0;i<icon.length;i++) { Map<String, Object> map=new HashMap<String, Object>(); map.put("image",icon[i]); map.put("text", iconName[i]); dataList.add(map); } return dataList; } //监听器 @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(this, "我是"+iconName[position], Toast.LENGTH_SHORT).show(); } }查看全部
-
android_gridview源代码 MainActivity.java package com.imooc.android_gridview; import android.R.integer; public class MainActivity extends Activity implements OnItemClickListener{ private GridView gridView;// 监听器使用接口方式 private List<Map<String,Object>> dataList; private int [] icon={R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher}; private String []iconName={"通讯录","日历","照相机","时钟","设置","语音","天气","浏览器","游戏"}; private SimpleAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//这里应该是main而不是activity_main gridView=(GridView) findViewById(R.id.gridView); /* * 1:准备数据源 * 2:新建适配器(SimpleAdapter) * 3:GridView加载适配器 * 4:GridView配置时间监听器(OnClickListener) */查看全部
-
fragment概要查看全部
-
加上progressbar查看全部
-
tab.setBackgroundColor(); tab.setTextColor(); tab.setDrawfullUnderline(); tab.setTabIndicatorColor(); tab.findViewById;查看全部
-
启用JavaScript查看全部
-
时间日期源代码 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" android:orientation="vertical" > <DatePicker android:id="@+id/datePicker" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TimePicker android:id="@+id/timePicker" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>查看全部
-
时间日期源代码 MainActivity.java续 //datePicker初始化 datePicker.init(year, cal.get(Calendar.MONTH), day,new OnDateChangedListener() { public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { setTitle(year+"-"+(monthOfYear+1)+"-"+dayOfMonth+"-"+hour+":"+minute); } }); timePicker.setOnTimeChangedListener(new OnTimeChangedListener() { public void onTimeChanged(TimePicker view , int hourOfDay, int minute) { setTitle(hourOfDay+":"+minute); } }); new DatePickerDialog(this, new OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { setTitle(year+"-"+(monthOfYear+1)+"-"+dayOfMonth+"-"+hour+":"+minute);} }, year,cal.get(Calendar.MONTH), day).show(); new TimePickerDialog(this, new OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { setTitle(hourOfDay+":"+minute); } }, hour, minute, true).show();//is24HourView:布尔变量,是否需要24小时计时单位显示 } }查看全部
-
使用webView打开新页面查看全部
-
时间日期源代码 MainActivity.java package com.imooc.datetimepicker; MainActivity.java import java.util.Calendar; import org.apache.http.impl.cookie.DateParseException; import android.R.integer; public class MainActivity extends Activity { private TimePicker timePicker; private DatePicker datePicker; private Calendar cal; private int year,month,day,hour,minute; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //获取日历的一个对象 cal=Calendar.getInstance(); //获取年月日时分秒的信息 year=cal.get(Calendar.YEAR); month=cal.get(Calendar.MONTH)+1; day=cal.get(Calendar.DAY_OF_MONTH); hour=cal.get(Calendar.HOUR_OF_DAY); minute=cal.get(Calendar.MINUTE); setTitle(year+"-"+month+"-"+day+"-"+hour+":"+minute); datePicker=(DatePicker)findViewById(R.id.datePicker); timePicker=(TimePicker) findViewById(R.id.timePicker);查看全部
-
获得访问权限查看全部
-
用WebView加载页面查看全部
-
ListView数据源查看全部
举报
0/150
提交
取消