/**
* 登录后将数据填写到主数据
*/
public void login(String login_nr)
{
//File f = new File(android.os.Environment.getExternalStorageDirectory()+"/info.txt"); //后面是跟你在sd卡上存放的xml路径
String path = this.ReadFilePatch("/info.txt"); File myfile=new File(path);
String login_file;
String login_nr_new;
if(myfile.exists())
{
login_file = ReadTxtFile(path);
// = "login,"+login_file;
login_nr_new = "login,"+login_file;
}else
{
login_nr_new = login_nr;
} login_nr_new.replaceAll("\n", ""); String[] array_nr = login_nr_new.split(",");
/**
* UserName + ','
+ CardNum + ',' + Star + ','
+ JobNum + ',' + UserJobDesc + ','
+ UserDept + ',' + UserWin
*/
//tv_name = (TextView)findViewById(R.id.ew_name);
//weiyongle if判断里的代码有问题,经过调试,发现array_nr的长度是1,这里直接访问array_nr[1]的数值,所以程序异常退出
if(array_nr.length>8){
tv_name.setText(array_nr[1]); //tv_code = (TextView)findViewById(R.id.ew_code);
tv_code.setText(array_nr[4]); tv_ckh = (TextView)findViewById(R.id.ew_ckh);
tv_ckh.setText(array_nr[7].replaceAll("\n", ""));
} if (array_nr.length>7)
{
TextView txt_bsjs = (TextView)findViewById(R.id.txt_bsjs);
txt_bsjs.setText(array_nr[8].replaceAll("\n", ""));
} TextView tv_userjob = (TextView)findViewById(R.id.txt_userjob); //ratingbar_Small = (RatingBar)findViewById(R.id.ratingbar_Small);
if (!array_nr[3].equals(""))
ratingbar_Small.setRating(Integer.parseInt(array_nr[3]));
else
ratingbar_Small.setRating(0); //tv_part = (TextView)findViewById(R.id.ew_part);
tv_part.setText(array_nr[6]); tv_bsjs = (TextView)findViewById(R.id.txt_bsjs);
//tv_bsjs.setText(array_nr[4]); img_user = (ImageView)findViewById(R.id.img_user); path = this.ReadFilePatch("/2.JPG"); Bitmap bmp = getlocalBitmap(path);//"/mnt/external_sd/2.jpg"); img_user.setImageBitmap(bmp); }

完整版:

 package cn.com.yutian.zwxt;

 import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask; import org.json.JSONArray;
import org.json.JSONObject; import com.androidquery.AQuery;
import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus; import cn.com.css.tax.product.android.common.utils.DataHelper;
import cn.com.css.tax.product.android.common.utils.ServiceHelper;
import cn.com.css.tax.product.android.common.utils.SettingsHelper;
import cn.com.css.tax.product.android.widget.fragment.AbstractAsyncActivity;
import cn.com.css.tax.product.android.widget.pulllist.RequestMessage;
import cn.com.yutian.zwxt.R; import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.AnimationDrawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.SimpleAdapter;
import android.widget.TextView ;
import android.widget.Toast; public class MianActivy extends Activity {
public TextView tv_name,tv_code,tv_ckh,tv_part,tv_bsjs,txt_time,txt_date,txt_mdate;
public RatingBar ratingbar_Small;
public TimeTextView tv_djs;
public AQuery aq;
private RequestMessage requestMessage; private ImageView imageView,img_user; private LinearLayout linearLayout; private AnimationDrawable animationDrawable; // wangling
private static final String PACKAGE_NAME = "com.wangling.anypcadmin"; // intent action to trigger wangling
public static final String PRINT_ACTION = "com.wangling.anypcadmin.AuthActivity"; private List list_bslc = new ArrayList();;
private Bitmap bmp; private ListView mListView;
private String[] mStrings = {"“三高”地点接纳设置无线寻呼发射基站的“三高”产权单位备案(... ","《承装(修、试)电力设施许可证》核发",
"《电工进网作业许可证》核发","《医疗器械出口销售证明书》",
"《医疗器械生产企业许可证》换证","《自费出国留学中介服务协议书》样本备案",
"安全技术防范产品生产审批","安全生产许可_1","安全生产许可_2"}; private View view_pjend;
private MediaPlayer mp1;
private Timer timer;
private int recLen; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main_1920);
/*
* 隐藏运行Android 4.0以上系统的平板的屏幕下方的状态栏
*/
/*try
{
String ProcID = "79";
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) ProcID = "42"; // ICS
// 需要root 权限
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "service call activity " + ProcID + " s16 com.android.systemui" }); // WAS
proc.waitFor();
}
catch (Exception ex)
{
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
} */
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
// getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE);
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); //aq = new AQuery(this); tv_name = (TextView)findViewById(R.id.ew_name);
//tv_name.setText(R.string.ew_name); tv_code = (TextView)findViewById(R.id.ew_code);
//tv_code.setText(R.string.ew_code); tv_ckh = (TextView)findViewById(R.id.ew_ckh);
//tv_ckh.setText(R.string.ew_ckh); tv_part = (TextView)findViewById(R.id.ew_part);
//tv_part.setText(R.string.ew_part); tv_bsjs = (TextView)findViewById(R.id.txt_bsjs);
//tv_bsjs.setText(""); ratingbar_Small = (RatingBar)findViewById(R.id.ratingbar_Small);
//ratingbar_Small.setMax(5); //handlertime.post(updateThread); linearLayout = (LinearLayout)findViewById(R.id.layout_main); //weiyongle 注释
initImgAnim(); //initwelcome();
Intent intent = getIntent();
// 获得Intent中的Extra
String value = intent.getDataString();
//weiyongle 注释
mp1 = MediaPlayer.create(MianActivy.this, R.raw.welcome); if (value==null)
{ value = ""; //weiyongle login方法有问题,所以这里先注释掉
// this.login(value); this.initImgAnim(); }
/*animationDrawable = new AnimationDrawable(); animationDrawable.addFrame(getResources().getDrawable(R.drawable.news_1), 1500);
animationDrawable.addFrame(getResources().getDrawable(R.drawable.news_2), 1500);
animationDrawable.addFrame(getResources().getDrawable(R.drawable.bszn), 1500); //设置手否重复播放,false为重复 animationDrawable.setOneShot(false); imageView.setImageDrawable(animationDrawable); animationDrawable.start();*/ //initImgAnim(); /*DisplayMetrics mDisplayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
int W = mDisplayMetrics.widthPixels;
int H = mDisplayMetrics.heightPixels; TextView txt_bsjs = (TextView)findViewById(R.id.txt_bsjs);*/ //txt_bsjs.setText("Width = " + String.valueOf(W) + "Height = " + H) // 得到传过来的Intent对象
/*Intent intent = getIntent();
// 获得Intent中的Extra
String value = intent.getDataString(); //输出 -pj
if (value==null)
{ value = "";
new AlertDialog.Builder(this).setTitle("Android 提示").setMessage(value).show();
this.login(value);
new AlertDialog.Builder(this).setTitle("Android 提示").setMessage("3").show();
this.initImgAnim();
new AlertDialog.Builder(this).setTitle("Android 提示").setMessage("4").show();
} if (value.equals("pj"))
{
this.login(value);
this.pj();
}else
if (value.indexOf("tp")!=-1)
{
this.login(value);
this.tp();
}else
if (value.indexOf("zt")!=-1)
{
this.login(value);
this.djs();
}else
if (value.indexOf("tz")!=-1)
{
this.login(value);
this.tz(value);
}else
if (value.indexOf("login")!=-1)
{
this.login(value);
this.initImgAnim();
}else
if (value.indexOf("bj")!=-1)
{
this.login(value);
this.bj();
}
else if (value.indexOf("hy")!=-1)
{
this.login(value);
mp1.start();
new Thread(){
@Override
public void run() {
//需要花时间的函数
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//向handler发消息
handler.sendEmptyMessage(0);
}}.start();
}else
{
initImgAnim();
}*/
} /**
* 得到数据
*/
public void getData(View view) { asyncTrans("10008001","{GBNF:test}","jsonCallBack"); } /**
* 普通报文通讯
*
* @param businessid
* 业务ID
* @param requestmessage
* 请求报文(JSONObject JSONArray结构)
* @param callback
* 需要实现的返回回调方法 public void jsonCallback(String url,JSONObject
* json, AjaxStatus status){}
*
*/
public void asyncTrans(String businessid, String requestmessage,
AjaxCallback<JSONObject> callback) {
final String url = DataHelper
.getServiceType(this) == DataHelper.SERVICE_TYPE_TEST ? getString(R.string.base_uri)
: SettingsHelper.getInstance(this)
.getStringSetting(SettingsHelper.SETTING_STR_IP)
+ "servlet/AndroidServlet";
Map<String, Object> params = new HashMap<String, Object>();
requestMessage = new RequestMessage(this);
requestMessage.setBusinessid(businessid);
requestMessage.setRequestmessage(requestmessage);
params.put(ServiceHelper.SERVICE_REQUEST_PARM_STR, requestMessage);
aq.progress(android.R.id.progress).ajax(url, params, JSONObject.class,
callback);
} /**
* 普通报文通讯
*
* @param businessid
* 业务ID
* @param requestmessage
* 请求报文(JSONObject JSONArray结构)
* @param callback
* 需要实现的返回回调方法 public void jsonCallback(String url,JSONObject
* json, AjaxStatus status){}
*
*/
public void asyncTrans(String businessid, String requestmessage,
String callback) {
final String url = getString(R.string.base_uri)
+ "servlet/AndroidServlet";
Map<String, Object> params = new HashMap<String, Object>();
requestMessage = new RequestMessage(this);
requestMessage.setBusinessid(businessid);
requestMessage.setRequestmessage(requestmessage);
params.put(ServiceHelper.SERVICE_REQUEST_PARM_STR, requestMessage);
aq.progress(android.R.id.progress).ajax(url, params, JSONObject.class,
this, callback); } /**
* 切换布局,将布局 内容嵌套到当前页面
*/
public void pj()
{
mp1 = MediaPlayer.create(MianActivy.this, R.raw.fwpj); mp1.start(); removeView(); View view =LayoutInflater.from(this).inflate(R.layout.main_pj_1280, null);
linearLayout.addView(view);
} public void jsonCallback(String url,JSONObject
json, AjaxStatus status){
System.out.println(json.toString());
} //第三种方式(Android1.6版本及以后的版本中提供了)
public void Imv2OnClick(View view){
/*Intent intent = new Intent(this, SearchViewActivity.class);
startActivity(intent);*/
removeView();
View v =LayoutInflater.from(this).inflate(R.layout.searchview_layout_1280, null);
linearLayout.addView(v);
mListView = (ListView) findViewById(R.id.list_view); //拿到ListView对象 final Resources res = getResources();
//final String[] bslc_title = res.getStringArray(R.array.string_array_bslc_title);
final String[] bslc_title2 =readbslc("");
final String[] bslc_nr =readbslc_nr("");
/*mListView.setAdapter(new ArrayAdapter<String>(
this,R.layout.list_bslc,R.id.tv_bslc_title1,bslc_title)); //添加适配器*/
List<Map<String, Object>> list_bslc = new ArrayList<Map<String, Object>>();
Map<String, Object> item; boolean dup = true;
int i = 0;
/*while (dup) {
item = new HashMap<String, Object>();
if (i<bslc_title2.length){
//判断刚好为单数的情况
if (i+1==bslc_title2.length)
{
item.put("title1",bslc_title2[i]);
list_bslc.add(item);
dup = false;
}else
{
item.put("title1",bslc_title2[i]);
item.put("title1",bslc_title2[i+1]);
list_bslc.add(item);
i=i+2;
if (i==bslc_title2.length)
{ dup = false;
}
}
} }*/
for (int i1=0;i1<bslc_title2.length;i1++)
{
item = new HashMap<String, Object>();
item.put("title1",bslc_title2[i1]);
list_bslc.add(item);
} SimpleAdapter adapter = new SimpleAdapter(this,list_bslc,R.layout.list_bslc,
//new String[]{"title1", "title2"},
new String[]{"title1"},
new int[]{R.id.tv_bslc_title1}); final View v_nr =LayoutInflater.from(this).inflate(R.layout.main_bslc_1280, null); mListView.setAdapter(adapter); mListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
mListView.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
removeView(); linearLayout.addView(v_nr); //final String[] bslc_nr = res.getStringArray(R.array.string_array_bslc_mx);
//final String[] bslc_title = res.getStringArray(R.array.string_array_bslc_title); TextView tv_title = (TextView)findViewById(R.id.txt_blsc_title);
tv_title.setText(bslc_title2[arg2]); TextView tv_nr = (TextView)findViewById(R.id.txt_nr);
tv_nr.setText(bslc_nr[arg2]); }
//@Override
/*public View getView(int position, View convert, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder; // 设置选中效果
if(selectedPosition == position)
{
holder.text.setTextColor(Color.BLUE);
holder.layout.setBackgroundColor(Color.YELLOW);
} else {
holder.text.setTextColor(Color.WHITE);
holder.layout.setBackgroundColor(Color.TRANSPARENT);
}
return convert;
} */
});
}
//第三种方式(Android1.6版本及以后的版本中提供了)
public void Imv3OnClick(View view){
/*Intent intent = new Intent(this, PjActivy.class);
startActivity(intent);*/
this.pj();
} private void removeView() {
//获取linearlayout子view的个数
int count = linearLayout.getChildCount();
if (count>0)
linearLayout.removeViewAt(count - 1);
//研究整个LAYOUT布局,
//因此,在remove的时候,只能操作的是0<location<count-1这个范围的
//在执行每次remove时,我们从count-2的位置即textview上面的那个控件开始删除~
if (count - 2 > 0) {
//count-2>0用来判断当前linearlayout子view数多于2个,即还有我们点add增加的button
linearLayout.removeViewAt(count - 2);
}
}
private void openBmp(String path)
{
if (bmp != null)// 如果不释放的话,不断取图片,将会内存不够
{
bmp.recycle(); bmp = BitmapFactory.decodeFile(path); imageView.setImageBitmap(bmp); } else {
bmp = BitmapFactory.decodeFile(path);
imageView.setImageBitmap(bmp);
}
}
public void ImvPjOnClick(View view){ String pjjg="0";
int vid = view.getId();
switch (vid)
{
case R.id.my_912:
pjjg="0";
break;
case R.id.jbmy_912:
pjjg="1";
break;
case R.id.tdbh_912:
pjjg="2";
break;
case R.id.xlbg_912:
pjjg="3";
break;
case R.id.ywbs_912:
pjjg="4";
break;
case R.id.ydgj_912:
pjjg="5";
break;
default:
pjjg="";
break;
}
String scode= String.valueOf(tv_code.getText()); ////员工号+//评价信息+//录像文件目录+//业务办理计时,写死5分钟
this.WriteData(scode.replaceAll(" ", "") + "," + pjjg + ",,5");
this.insertpjxx(scode,pjjg);
removeView();
/*view_pjend =LayoutInflater.from(this).inflate(R.layout.pj_end, null);
linearLayout.addView(view_pjend);*/ View v =LayoutInflater.from(this).inflate(R.layout.anima_1920, null);
linearLayout.addView(v); imageView = (ImageView)findViewById(R.id.animationviewbg3); imageView.setImageResource(R.drawable.thanks); mp1 = MediaPlayer.create(MianActivy.this, R.raw.thanks); mp1.start(); new Thread(){
@Override
public void run() {
//需要花时间的函数
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//向handler发消息
handler.sendEmptyMessage(0);
}}.start();
/*try {
Thread.currentThread();
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/ //initImgAnim();
}
private void initImgAnim()
{ removeView();
View v =LayoutInflater.from(this).inflate(R.layout.anima_1920, null);
linearLayout.addView(v); animationDrawable = new AnimationDrawable();
animationDrawable.addFrame(getResources().getDrawable(R.drawable.zgm912), 3000);
animationDrawable.addFrame(getResources().getDrawable(R.drawable.ad912), 3000);
//animationDrawable.addFrame(getResources().getDrawable(R.drawable.ad2), 3000);
//animationDrawable.addFrame(getResources().getDrawable(R.drawable.bszn), 1500); //设置手否重复播放,false为重复 animationDrawable.setOneShot(false); imageView = (ImageView)findViewById(R.id.animationviewbg3); imageView.setImageDrawable(animationDrawable); animationDrawable.start();
}
private Handler handler = new Handler(){ @Override
public void handleMessage(Message msg) { initImgAnim();
}}; private void initwelcome()
{ removeView();
View v =LayoutInflater.from(this).inflate(R.layout.anima_1920, null);
linearLayout.addView(v); imageView = (ImageView)findViewById(R.id.animationviewbg3); imageView.setImageResource(R.drawable.welcome); } public void djs()
{ mp1 = MediaPlayer.create(MianActivy.this, R.raw.stop);
mp1.start();
removeView();
View v =LayoutInflater.from(this).inflate(R.layout.mian_stop_1280, null);
linearLayout.addView(v); tv_djs= (TimeTextView)findViewById(R.id.txt_djs);
//开始计时,性能测试用nanoTime会更精确,因为它是纳秒级的
long startTime = System.nanoTime();
long[] times = {0,0,15,0};
tv_djs.setTimes(times);
//特卖倒计时控件
//已经在倒计时的时候不再开启计时
if(!tv_djs.isRun())
{
tv_djs.run();
}
//停止计时
long endTime = System.nanoTime();
//耗时
long spendTime = (endTime - startTime); Log.d("GoogleIO", "--sumTime:"+String.valueOf(spendTime));
//timer = new Timer();
//recLen = 10; //timer.schedule(task, 1000, 1000); // timeTask } public void djs(View view)
{ removeView();
View v =LayoutInflater.from(this).inflate(R.layout.mian_stop_1280, null);
linearLayout.addView(v); tv_djs= (TimeTextView)findViewById(R.id.txt_djs);
//开始计时,性能测试用nanoTime会更精确,因为它是纳秒级的
long startTime = System.nanoTime();
long[] times = {0,0,15,0};
tv_djs.setTimes(times);
//特卖倒计时控件
//已经在倒计时的时候不再开启计时
if(!tv_djs.isRun())
{
tv_djs.run();
}
//停止计时
long endTime = System.nanoTime();
//耗时
long spendTime = (endTime - startTime); Log.d("GoogleIO", "--sumTime:"+String.valueOf(spendTime));
//timer = new Timer();
//recLen = 10; //timer.schedule(task, 1000, 1000); // timeTask }
TimerTask task = new TimerTask() {
@Override
public void run() { runOnUiThread(new Runnable() { // UI thread
@Override
public void run() {
recLen--;
tv_djs.setText("倒计时时间("+recLen+")");
if(recLen < 0){
timer.cancel();
tv_djs.setVisibility(View.GONE);
}
}
});
}
}; public static Bitmap getlocalBitmap(String url)
{ File f = new File(url); //后面是跟你在sd卡上存放的xml路径
String path=f.getAbsolutePath();
File myfile=new File(path);
if(myfile.exists())
{
//hasFile=1;
}
try {
FileInputStream fileIS = new FileInputStream(path);
return BitmapFactory.decodeStream(fileIS);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} } /**
* 切换布局,将布局 内容嵌套到当前页面
*/
public void tp()
{
removeView();
View v =LayoutInflater.from(this).inflate(R.layout.anima_1280, null);
linearLayout.addView(v); imageView = (ImageView)findViewById(R.id.animationviewbg3); Bitmap bmp = getlocalBitmap("/mnt/external_sd/1.jpg"); imageView.setImageBitmap(bmp);
} /**
* 切换布局,将布局 内容嵌套到当前页面
*/
public void tz(String tznr)
{ removeView(); final View v_nr =LayoutInflater.from(this).inflate(R.layout.main_bslc_1280, null);
String[] array = tznr.split(",");
linearLayout.addView(v_nr); TextView tv_title = (TextView)findViewById(R.id.txt_blsc_title);
tv_title.setText("临时通知");
String path = this.ReadFilePatch("/tzxx.txt"); File myfile=new File(path);
String login_file="";
String login_nr_new;
if(myfile.exists())
{
login_file = ReadTxtFile(path);
// = "login,"+login_file; } TextView tv_nr = (TextView)findViewById(R.id.txt_nr);
tv_nr.setText(login_file); }
/**
* 切换布局,将布局 内容嵌套到当前页面
*/
public void bj()
{ removeView(); final View v_nr =LayoutInflater.from(this).inflate(R.layout.bslc_bj_1280, null); linearLayout.addView(v_nr); }
/**
* 登录后将数据填写到主数据
*/
public void login(String login_nr)
{
//File f = new File(android.os.Environment.getExternalStorageDirectory()+"/info.txt"); //后面是跟你在sd卡上存放的xml路径
String path = this.ReadFilePatch("/info.txt"); File myfile=new File(path);
String login_file;
String login_nr_new;
if(myfile.exists())
{
login_file = ReadTxtFile(path);
// = "login,"+login_file;
login_nr_new = "login,"+login_file;
}else
{
login_nr_new = login_nr;
} login_nr_new.replaceAll("\n", ""); String[] array_nr = login_nr_new.split(",");
/**
* UserName + ','
+ CardNum + ',' + Star + ','
+ JobNum + ',' + UserJobDesc + ','
+ UserDept + ',' + UserWin
*/
//tv_name = (TextView)findViewById(R.id.ew_name);
//weiyongle if判断里的代码有问题,经过调试,发现array_nr的长度是1,这里直接访问array_nr[1]的数值,所以程序异常退出
if(array_nr.length>8){
tv_name.setText(array_nr[1]); //tv_code = (TextView)findViewById(R.id.ew_code);
tv_code.setText(array_nr[4]); tv_ckh = (TextView)findViewById(R.id.ew_ckh);
tv_ckh.setText(array_nr[7].replaceAll("\n", ""));
} if (array_nr.length>7)
{
TextView txt_bsjs = (TextView)findViewById(R.id.txt_bsjs);
txt_bsjs.setText(array_nr[8].replaceAll("\n", ""));
} TextView tv_userjob = (TextView)findViewById(R.id.txt_userjob); //ratingbar_Small = (RatingBar)findViewById(R.id.ratingbar_Small);
if (!array_nr[3].equals(""))
ratingbar_Small.setRating(Integer.parseInt(array_nr[3]));
else
ratingbar_Small.setRating(0); //tv_part = (TextView)findViewById(R.id.ew_part);
tv_part.setText(array_nr[6]); tv_bsjs = (TextView)findViewById(R.id.txt_bsjs);
//tv_bsjs.setText(array_nr[4]); img_user = (ImageView)findViewById(R.id.img_user); path = this.ReadFilePatch("/2.JPG"); Bitmap bmp = getlocalBitmap(path);//"/mnt/external_sd/2.jpg"); img_user.setImageBitmap(bmp); } //读取文本文件中的内容
public static String ReadTxtFile(String strFilePath)
{
String path = strFilePath;
String content = ""; //文件内容字符串
//打开文件
File file = new File(path);
//如果path是传递过来的参数,可以做一个非目录的判断
if (file.isDirectory())
{
Log.d("TestFile", "The File doesn't not exist.");
}
else
{
try {
InputStream instream = new FileInputStream(file);
if (instream != null)
{ InputStreamReader inputreader = new InputStreamReader(instream);
BufferedReader buffreader ;
BufferedInputStream in = new BufferedInputStream(instream);
in.mark(4);
byte[]first3bytes = new byte[3];
in.read(first3bytes);
in.reset();
if(first3bytes[0] == (byte) 0xEF && first3bytes[1] == (byte) 0xBB
&&first3bytes[2] == (byte) 0xBF) {// utf-8 buffreader = new BufferedReader(new InputStreamReader(in, "utf-8")); }else if (first3bytes[0] == (byte) 0xFF
&&first3bytes[1] == (byte) 0xFE) { buffreader = new BufferedReader(
new InputStreamReader(in,"unicode"));
}else if (first3bytes[0] == (byte) 0xFE
&&first3bytes[1] == (byte) 0xFF) { buffreader = new BufferedReader(new InputStreamReader(in,
"utf-16be"));
}else if (first3bytes[0] == (byte) 0xFF
&&first3bytes[1] == (byte) 0xFF) { buffreader = new BufferedReader(new InputStreamReader(in,
"utf-16le"));
}else { buffreader = new BufferedReader(new InputStreamReader(in, "GBK"));
}
//BufferedReader buffreader = new BufferedReader(inputreader);
String line;
//分行读取
while (( line = buffreader.readLine()) != null) {
content += line + "\n";
}
instream.close();
}
}
catch (java.io.FileNotFoundException e)
{
Log.d("TestFile", "The File doesn't not exist.");
}
catch (IOException e)
{
Log.d("TestFile", e.getMessage());
}
}
return content;
}
//读取文本文件中的内容
public String ReadFilePatch(String strFileName)
{
File f = new File(android.os.Environment.getExternalStorageDirectory() + strFileName); //后面是跟你在sd卡上存放的xml路径
String path=f.getAbsolutePath(); File myfile=new File(path); if(myfile.exists())
{
return path;
} if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ f = new File(android.os.Environment.getExternalStorageDirectory() + strFileName); //后面是跟你在sd卡上存放的xml路径
path=f.getAbsolutePath(); myfile=new File(path);
if(myfile.exists())
{
return path;
}
} f = new File(android.os.Environment.getDownloadCacheDirectory() + strFileName); //后面是跟你在sd卡上存放的xml路径
path=f.getAbsolutePath(); myfile=new File(path);
if(myfile.exists())
{
return path;
} f = new File("/storage/sdcard0/"+ strFileName); //后面是跟你在sd卡上存放的xml路径
path=f.getAbsolutePath(); myfile=new File(path);
if(myfile.exists())
{
return path;
}
return "";
} private void WriteData(String pjdata) {
String filePath = this.ReadFilePatch("/info.txt"); filePath = filePath.replaceAll("info.txt", "");
//new AlertDialog.Builder(this).setTitle("Android 提示").setMessage(filePath).show(); String fileName = "pj.txt"; writeTxtToFile(pjdata, filePath, fileName);
} // 将字符串写入到文本文件中
public void writeTxtToFile(String strcontent, String filePath, String fileName) {
//生成文件夹之后,再生成文件,不然会出错
makeFilePath(filePath, fileName); String strFilePath = filePath+fileName;
// 每次写入时,都换行写
String strContent = strcontent + "\r\n";
try {
File file = new File(strFilePath);
if (!file.exists()) {
Log.d("TestFile", "Create the file:" + strFilePath);
file.getParentFile().mkdirs();
file.createNewFile();
}
RandomAccessFile raf = new RandomAccessFile(file, "rwd");
raf.seek(file.length());
raf.write(strContent.getBytes());
raf.close();
} catch (Exception e) {
Log.e("TestFile", "Error on write File:" + e);
}
} // 生成文件
public File makeFilePath(String filePath, String fileName) {
File file = null;
makeRootDirectory(filePath);
try {
file = new File(filePath + fileName);
if (!file.exists()) {
file.createNewFile();
}
} catch (Exception e) {
e.printStackTrace();
}
return file;
} // 生成文件夹
public static void makeRootDirectory(String filePath) {
File file = null;
try {
file = new File(filePath);
if (!file.exists()) {
file.mkdir();
}
} catch (Exception e) {
Log.i("error:", e+"");
}
} public void insertpjxx(String user_code,String pjjg)
{
//初始化数据库
DatabaseHelper helper = new DatabaseHelper(this);
SQLiteDatabase database = helper.getReadableDatabase(); ContentValues value = new ContentValues();
//Iterator<Map<String, Object>> sListIterator = myapp.getList_dcjsxx().iterator();
//while(sListIterator.hasNext()){ value.put("user_code", user_code);
value.put("pjsj", pjjg); value.put("jk_time", System.currentTimeMillis()); database.insert("tb_dcxx_mx", null, value);
//}
} /**
* 登录后将数据填写到主数据
* @throws Exception
*/
public String[] readbslc(String login_nr)
{
//File f = new File(android.os.Environment.getExternalStorageDirectory()+"/info.txt"); //后面是跟你在sd卡上存放的xml路径
String path = this.ReadFilePatch("/bslc.txt"); File myfile=new File(path);
String login_file;
String login_nr_new; if(myfile.exists())
{
login_file = ReadTxtFile(path);
// = "login,"+login_file;
//bslcjs = JSONObject.fromString(login_file);
try {
String s = "["+login_file.replaceAll("\\}\n\\{", "\\},\\{")+"]";
list_bslc =DataHelper.getList(s);
String[] title1 = new String[list_bslc.size()];
for (int i =0 ;i<list_bslc.size();i++)
{
Map jsonObject = (Map) list_bslc.get(i);
title1[i] = (String) jsonObject.get("bslc_title");
}
return title1; } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }else
{
return mStrings;
} return mStrings; }
/**
* 登录后将数据填写到主数据
* @throws Exception
*/
public String[] readbslc_nr(String login_nr)
{ if (list_bslc!=null&&list_bslc.size()>0)
{
String[] nr1 = new String[list_bslc.size()];
for (int i =0 ;i<list_bslc.size();i++)
{
Map jsonObject = (Map) list_bslc.get(i);
nr1[i] = (String) jsonObject.get("bslc_nr");
}
return nr1;
}
return this.getResources().getStringArray(R.array.string_array_bslc_mx); //return mStrings; } @Override
protected void onDestroy()
{
// TODO Auto-generated method stub
/*
* 恢复运行Android 4.0以上系统的平板的屏幕下方的状态栏
*/
try
{
Process proc = Runtime.getRuntime().exec(new String[] { "am", "startservice", "-n", "com.android.systemui/.SystemUIService" });
proc.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
}
super.onDestroy();
} /*@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.startup, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item)
{
// TODO Auto-generated method stub
switch (item.getItemId())
{
case R.id.action_exit:
finish();
break;
}
return true;
}*/
private String DEFAULT_TIME_FORMAT = "HH:mm"; private String DEFAULT_DATE_FORMAT = "yyyy/MM/dd"; private String time=""; //创建Handler对象 Handler handlertime = new Handler(); //新建一个线程对象 Runnable updateThread = new Runnable(){ //将要执行的操作写在线程对象的run方法当中 public void run(){ handlertime.postDelayed(updateThread, 60*1000); //调用Handler的postDelayed()方法 //这个方法的作用是:将要执行的线程对象放入到队列当中,待时间结束后,运行制定的线程对象 //第一个参数是Runnable类型:将要执行的线程对象 //第二个参数是long类型:延迟的时间,以毫秒为单位 SimpleDateFormat dateFormatter = new SimpleDateFormat(DEFAULT_TIME_FORMAT); time = dateFormatter.format(Calendar.getInstance().getTime());
/*txt_time = (TextView)findViewById(R.id.txt_time);
if (txt_time.getText().toString().indexOf(":")>-1)
{
txt_time.setText(time.replaceAll(":", " "));
}else
{
txt_time.setText(time);
} dateFormatter = new SimpleDateFormat(DEFAULT_DATE_FORMAT); String date = dateFormatter.format(Calendar.getInstance().getTime()); txt_date = (TextView)findViewById(R.id.txt_date);
txt_date.setText(date); txt_mdate = (TextView)findViewById(R.id.txt_mdate);
txt_mdate.setText(DataString.StringData());*/
//txt_mdate.setText(); } }; }

longquan的更多相关文章

  1. linux查找webshell

    原文出处:http://my.oschina.net/longquan/blog/155905 首先认识一下小马,一般大马容易暴露,骇客都会留一手,把小马加入正常PHP文件里面 <?php ev ...

  2. ios ViewController 页面跳转

    从一个Controller跳转到另一个Controller时,一般有以下2种: 1.利用UINavigationController,调用pushViewController,进行跳转:这种采用压栈和 ...

  3. iphone document 图片存储和读取

    转载自:http://longquan.iteye.com/blog/1669990 存: //此处首先指定了图片存取路径(默认写到应用程序沙盒 中) NSArray *paths = NSSearc ...

  4. 任意2个io直接驱动LCD1602,并且不需外加芯片(转)

    http://www.amobbs.com/thread-4301955-1-1.html *此处只摘录部分内容,详细内容请关注原贴. 这就是电路,细心的朋友会发现实物图中有几个贴片的阻容件,秘密就在 ...

  5. 字王大藏经体v0.1概念版

    字王大藏经体v0.1概念版 zw-dzj 字王大藏经体v0.1概念版,是字王<中华大字库>2018版升级过程当中,在Github搜索资源时的意外惊喜. 大藏经为佛教经典的总集,简称为藏经. ...

  6. rainmeter 修正天气插件信息不准确 设置居住城市

    rainmeter天气插件的原理是用爬虫抓取一个天气网页然后用自带的那一套正则表达式匹配出天气信息 在国外官网社区下载的插件的天气信息城市都会出现问题(因为插件作者又不知道你在哪),解决方法是在原基础 ...

  7. 中国城市json

    [{ "label": "北京Beijing010", "name": "北京", "pinyin" ...

  8. 小程序-demo:天气预报

    ylbtech-小程序-demo:天气预报 1.返回顶部 1.app.js //app.js App({ //系统事件 onLaunch: function () {//小程序初始化事件 var th ...

  9. 20180725利用pmm监控管理mysql

    转自:https://www.percona.com/doc/percona-monitoring-and-management/architecture.html 报警机制https://www.p ...

随机推荐

  1. TortoiseHg 学习笔记

    0.前言     TortoiseHg是分布式的源代码管理工具Mercurial的GUIclient. mercurial 作为3大主流的分布式源代码管理工具.已经被广泛的使用.比如 googleco ...

  2. Visual Studio 2013 编译 64 位 Python 的 C 扩展 (使用 PyObject 包装)

    对于 32 位 Python 的 C 扩展,以前用过 mingW32 编译, 但是 mingW32 不支持 64 位 Python 的 C 扩展编译,详情可见 stackoverflow,这位前辈的大 ...

  3. Flask框架简介,常用扩展包及两大核心

    Flask诞生于2010年,是Armin ronacher(人名)用 Python 语言基于 Werkzeug 工具箱编写的轻量级Web开发框架. Flask 本身相当于一个内核,其他几乎所有的功能都 ...

  4. 20175310 《Java程序设计》第8周学习总结

    20175310 <Java程序设计>第8周学习总结 本周博客: https://www.cnblogs.com/xicyannn/p/10722004.html 教材学习内容总结 这周学 ...

  5. 【LOJ 2145】「SHOI2017」分手是祝愿

    LOJ 2145 100pts 这题...BT啊 首先我们很容易想出\(dp(msk)\)表示现在灯开关的情况是\(msk\),期望通过多少步走到终结态. 很明显\(dp(msk)=\frac{1}{ ...

  6. Java IO(五)——字符流进阶及BufferedWriter、BufferedReader

    一.字符流和字节流的区别 拿一下上一篇文章的例子: package com.demo.io; import java.io.File; import java.io.FileReader; impor ...

  7. ASP.NET Core 2.1 源码学习之 Options[1]:Configure

    配置的本质就是字符串的键值对,但是对于面向对象语言来说,能使用强类型的配置是何等的爽哉! 目录 ASP.NET Core 配置系统 强类型的 Options Configure 方法 Configur ...

  8. [SDOI2017]天才黑客[最短路、前缀优化建图]

    题意 一个 \(n\) 点 \(m\) 边的有向图,还有一棵 \(k\) 个节点的 trie ,每条边上有一个字符串,可以用 trie 的根到某个节点的路径来表示.每经过一条边,当前携带的字符串就会变 ...

  9. 阿里云 Windows Server 2012 r2 部署asp.net mvc网站 平坑之旅

    做了多年的Web开发工作,网站部署也不在话下,可每次部署却并不是十分顺利,将本次在阿里云服务器上部署asp.net mvc网站遇到的问题记录如下. 平台是阿里云ECS,操作系统是 Windows Se ...

  10. Day5 Pyhton基础之编码与解码(四)

    1.编码与解码 1.1现在常用的编码类型