当前位置: 编程技术>移动开发
本页文章导读:
▪9.BBS系统项目配置列表 九.BBS系统项目配置列表
编号
配置项
基线
所属人
状态
版本
属性
来源
1
BBS
系统初步成本分析目标时间
表
功能
黎飞
初步调查
1
.........
▪ 代码开启封锁Gps 代码开启关闭Gps
在Android 2.2以后才可使用
/**
* Gets the state of GPS location.
*
* @param context
* @return true if enabled.
*/
private static boolean getGpsState(Context context) {
ContentResolver resolver = context.ge.........
▪ ListView中加下加FootView和自动加载listview条目 ListView中加上加FootView和自动加载listview条目
package com.accesscompany.testlistadapter;
import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Dial.........
[1]9.BBS系统项目配置列表
来源: 互联网 发布时间: 2014-02-18
九.BBS系统项目配置列表
编号
配置项
基线
所属人
状态
版本
属性
来源
1
BBS
系统初步成本分析目标时间
表
功能
黎飞
初步调查
1
Doc
调研
2
BBS
系统需求问题和需求声明
功能
宋颖妍
可行性分析
1
PPT
开发
8
BBS
系统详细说明
需求
皮贝
初步计划
1
Doc
总结
9
BBS
系统需求
需求
黎少思
初步计划
1
Doc
总结
10
Web
界面需求说明
需求
张文
初步计划
1
Doc
设计
11
BBS
系统逻辑架构
开发
黎飞
初始开发
1
Doc
设计
12
BBS
系统详细设计
开发
皮贝
初始开发
1
Doc
设计
13
BBS
系统测试计划
开发
宋颖妍
初始开发
1
Doc
设计
14
项目源文件以及
sql
文件
开发
张文
初始开发
1
Java,sql
开发
15
归档
war
文件
开发
黎少思
初始开发
1
War
开发
16
软件产品说明书
产品
李萍
实现
1
Doc
开发
18
用户文档
产品
李萍
实现
1
Doc
开发
[2] 代码开启封锁Gps
来源: 互联网 发布时间: 2014-02-18
代码开启关闭Gps
在Android 2.2以后才可使用
/** * Gets the state of GPS location. * * @param context * @return true if enabled. */ private static boolean getGpsState(Context context) { ContentResolver resolver = context.getContentResolver(); boolean open = Settings.Secure.isLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER); System.out.println("getGpsState:" + open); return open; } /** * Toggles the state of GPS. * * @param context */ private void toggleGps(Context context) { ContentResolver resolver = context.getContentResolver(); boolean enabled = getGpsState(context); Settings.Secure.setLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER, !enabled); }
需要添加权限
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
在 AndroidManifest.xml中添加系统权限: android:sharedUserId="android.uid.system"
例如:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="android.uid.system"
>
1 楼
lifeijiyuan
2011-07-21
问题解决,谢谢
2 楼
虚轻轻的飘过
2011-10-19
为什么我加了
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
两个权限,都是提示
10-19 04:44:51.613: ERROR/AndroidRuntime(445): Caused by: java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
请问怎么回事?
最后加的那个结果提示Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE错误。
那个是干什么的到底?
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
两个权限,都是提示
10-19 04:44:51.613: ERROR/AndroidRuntime(445): Caused by: java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
请问怎么回事?
最后加的那个结果提示Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE错误。
那个是干什么的到底?
[3] ListView中加下加FootView和自动加载listview条目
来源: 互联网 发布时间: 2014-02-18
ListView中加上加FootView和自动加载listview条目
package com.accesscompany.testlistadapter; import java.util.ArrayList; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.Color; import android.graphics.Paint; import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.UnderlineSpan; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.AbsListView; import android.widget.BaseAdapter; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.AbsListView.OnScrollListener; import android.widget.LinearLayout.LayoutParams; public class MainActivity extends Activity { private static final String TAG = "MainActivity"; /** * 设置布局显示属性 */ private LayoutParams mLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); /** * 设置布局显示目标最大化属性 */ private LayoutParams FFlayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); private ProgressBar progressBar; // My Adapter, based on BaseAdapter private MyListAdapter mAdapter = null; private int lastItem = 0; LinearLayout loadingLayout; ListView mainList; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView we = (TextView) findViewById(R.id.wen); SpannableStringBuilder style = new SpannableStringBuilder("谢红霞"); style.setSpan(new UnderlineSpan(), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); we.setText(style); LinearLayout layout = new LinearLayout(this); // 设置布局 水平方向 layout.setOrientation(LinearLayout.HORIZONTAL); // 进度条 progressBar = new ProgressBar(this); // 进度条显示位置 progressBar.setPadding(0, 0, 15, 0); // 把进度条加入到layout中 // layout.addView(progressBar, mLayoutParams); // 文本内容 TextView textView = new TextView(this); textView.setText("展开更多"); textView.setGravity(Gravity.CENTER); textView.setPadding(100, 10, 0, 20); textView.setTextColor(Color.BLUE); textView.setTextSize(20); // 把文本加入到layout中 layout.addView(textView, FFlayoutParams); // 设置layout的重力方向,即对齐方式是 layout.setGravity(Gravity.CENTER); // 设置ListView的页脚layout loadingLayout = new LinearLayout(this); loadingLayout.addView(layout, mLayoutParams); loadingLayout.setGravity(Gravity.CENTER); loadingLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { /* * if (adapter.count<=41) { adapter.count += 10; * adapter.notifyDataSetChanged(); * * } */ if (mAdapter.mData.size() < 50) { for (int i = 0; i < 10; i++) { MyListItem list_item = new MyListItem(); list_item.setTitle("商家XXX" + i); list_item.setText("XXXXXXXXXX街道XXX楼" + i); mAdapter.addItem(list_item); } mAdapter.notifyDataSetChanged(); } else { mainList.removeFooterView(loadingLayout); } } }); mAdapter = new MyListAdapter(); for (int i = 0; i < 10; i++) { MyListItem list_item = new MyListItem(); list_item.setTitle("title" + i); list_item.setText("text" + i); mAdapter.addItem(list_item); } mainList = (ListView) findViewById(R.id.mainlist); mainList.addFooterView(loadingLayout); mainList.setAdapter(mAdapter); mainList.setOnScrollListener(new OnScrollListener() { public void onScroll(AbsListView v, int firstVisibleItem, int visibleItemCount, int totalItemCount) { Log.i(TAG, "Scroll>>>first: " + firstVisibleItem + ", visible: " + visibleItemCount + ", total: " + totalItemCount); lastItem = firstVisibleItem + visibleItemCount - 1; Log.i(TAG, "Scroll>>>lastItem:" + lastItem); // 显示50条ListItem,即0-49,因为onScroll是在“滑动”执行过之后才触发,所以用adapter.count<=41作条件 /* * if (adapter.count<=41) { if * (firstVisibleItem+visibleItemCount==totalItemCount) { * adapter.count += 10; adapter.notifyDataSetChanged(); * listView.setSelection(lastItem); int * currentPage=adapter.count/10; * Toast.makeText(getApplicationContext(), "第"+currentPage+"页", * Toast.LENGTH_LONG).show(); } } else { * listView.removeFooterView(loadingLayout); } */ } @Override public void onScrollStateChanged(AbsListView v, int state) { if (lastItem == mAdapter.mData.size() && state == OnScrollListener.SCROLL_STATE_IDLE) { /* * Log.i(TAG,"ScrollStateChanged>>>state:"+state+"lastItem:" * + lastItem); * //显示50条ListItem,即0-49,因为onScrollStateChanged是在 * “拖动滑动”执行过之后才触发,所以用adapter.count<=41作条件 if * (adapter.count<=41) { adapter.count += 10; * adapter.notifyDataSetChanged(); * * }else{ listView.removeFooterView(loadingLayout); } */ } } }); } private OnClickListener listenBtnListener = new OnClickListener() { public void onClick(View v) { Log.i(TAG, "Clicked view: " + v + ", parent: " + v.getParent()); ViewHolder vh = (ViewHolder) ((View) v.getParent()).getTag(); AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this); ad.setTitle("Listen button clicked"); ad.setMessage("The " + vh.position + " listen button clicked"); ad.setPositiveButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.i(TAG, "Listen button click dialog disposing..."); } }); ad.show(); } }; private OnClickListener downloadBtnListener = new OnClickListener() { public void onClick(View v) { Log.i(TAG, "Clicked view: " + v + ", parent: " + v.getParent()); ViewHolder vh = (ViewHolder) ((View) v.getParent()).getTag(); AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this); ad.setTitle("Download button clicked"); ad.setMessage("The " + vh.position + " download button clicked"); ad.setPositiveButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.i(TAG, "Download button click dialog disposing..."); } }); ad.show(); } }; private class MyListAdapter extends BaseAdapter { private ArrayList<MyListItem> mData = new ArrayList<MyListItem>(); private LayoutInflater mInflater; public MyListAdapter() { mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public void addItem(MyListItem item) { mData.add(item); notifyDataSetChanged(); } @Override public int getCount() { return mData.size(); } @Override public MyListItem getItem(int position) { return mData.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { Log.i(TAG, "getView " + position + " " + convertView + "; parent: " + parent); ViewHolder holder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.listitem_layout, null); holder = new ViewHolder(); holder.tvTitle = (TextView) convertView .findViewById(R.id.itemTitle); holder.tvText = (TextView) convertView .findViewById(R.id.itemText); holder.btnDownload = (TextView) convertView .findViewById(R.id.btnDownload); holder.position = position; convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.tvTitle.setText(mData.get(position).getTitle()); holder.tvText.setText(mData.get(position).getText()); holder.btnDownload.setText("不完整"); return convertView; } } public class ViewHolder { public TextView tvTitle; public TextView tvText; public TextView btnDownload; public int position; } }
package com.accesscompany.testlistadapter; public class MyListItem { private String title = null; private String text = null; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getText() { return text; } public void setText(String text) { this.text = text; } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="100dip"> <TextView android:text="TextView01" android:layout_height="wrap_content" android:textSize="18dip" android:text android:layout_marginLeft="13dip" android:layout_marginTop="10dip" android:textColor="@color/blue" android:layout_width="200dip" android:id="@+id/itemTitle" /> <TextView android:text="TextView02" android:textColor="@color/black" android:textSize="18dip" android:layout_height="wrap_content" android:layout_marginBottom="10dip" android:paddingBottom="10dip" android:layout_marginLeft="13dip" android:layout_width="200dip" android:layout_below="@+id/itemTitle" android:id="@+id/itemText" /> <TextView android:layout_width="60dip" android:layout_height="wrap_content" android:id="@+id/btnDownload" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:focusable="false" android:textColor="@color/black" android:scaleType="fitCenter" /> </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@drawable/transparent_background" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="50dip"> <TextView android:text="重新定位" android:layout_width="220dip" android:textColor="@color/blue" android:textSize="20dip" android:paddingLeft="5dip" android:paddingTop="5dip" android:layout_height="wrap_content" /> <TextView android:text="新建商家" android:layout_width="wrap_content" android:id="@+id/wen" android:layout_height="wrap_content" android:textColor="@color/blue" android:textSize="20dip" android:paddingLeft="5dip" android:paddingTop="5dip" android:layout_alignParentRight="true" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="50dip"> <EditText android:layout_width="200dip" android:layout_marginLeft="20dip" android:id="@+id/at" android:textColor="@color/black" android:textSize="20dip" android:paddingLeft="5dip" android:paddingTop="5dip" android:layout_height="wrap_content" /> <Button android:text="搜索" android:layout_width="80dip" android:layout_height="wrap_content" android:textColor="@color/black" android:textSize="20dip" android:paddingLeft="5dip" android:paddingTop="5dip" android:layout_alignParentRight="true" /> </LinearLayout> <ListView android:layout_width="wrap_content" android:layout_height="300dip" android:cacheColorHint="#00000000" android:divider="#000000" android:dividerHeight="1px" android:stretchMode="columnWidth" android:id="@+id/mainlist"> </ListView> <TextView android:text="选项" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/blue" android:textSize="20dip" android:paddingLeft="235dip" android:paddingTop="15dip" android:layout_alignParentRight="true" /> </LinearLayout>
最新技术文章: