longquan
/**
* 登录后将数据填写到主数据
*/
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的更多相关文章
- linux查找webshell
原文出处:http://my.oschina.net/longquan/blog/155905 首先认识一下小马,一般大马容易暴露,骇客都会留一手,把小马加入正常PHP文件里面 <?php ev ...
- ios ViewController 页面跳转
从一个Controller跳转到另一个Controller时,一般有以下2种: 1.利用UINavigationController,调用pushViewController,进行跳转:这种采用压栈和 ...
- iphone document 图片存储和读取
转载自:http://longquan.iteye.com/blog/1669990 存: //此处首先指定了图片存取路径(默认写到应用程序沙盒 中) NSArray *paths = NSSearc ...
- 任意2个io直接驱动LCD1602,并且不需外加芯片(转)
http://www.amobbs.com/thread-4301955-1-1.html *此处只摘录部分内容,详细内容请关注原贴. 这就是电路,细心的朋友会发现实物图中有几个贴片的阻容件,秘密就在 ...
- 字王大藏经体v0.1概念版
字王大藏经体v0.1概念版 zw-dzj 字王大藏经体v0.1概念版,是字王<中华大字库>2018版升级过程当中,在Github搜索资源时的意外惊喜. 大藏经为佛教经典的总集,简称为藏经. ...
- rainmeter 修正天气插件信息不准确 设置居住城市
rainmeter天气插件的原理是用爬虫抓取一个天气网页然后用自带的那一套正则表达式匹配出天气信息 在国外官网社区下载的插件的天气信息城市都会出现问题(因为插件作者又不知道你在哪),解决方法是在原基础 ...
- 中国城市json
[{ "label": "北京Beijing010", "name": "北京", "pinyin" ...
- 小程序-demo:天气预报
ylbtech-小程序-demo:天气预报 1.返回顶部 1.app.js //app.js App({ //系统事件 onLaunch: function () {//小程序初始化事件 var th ...
- 20180725利用pmm监控管理mysql
转自:https://www.percona.com/doc/percona-monitoring-and-management/architecture.html 报警机制https://www.p ...
随机推荐
- 【vue】vue +element 搭建项目,要求既支持pc端又支持移动端
使用场景:有适配pc端改为适配pc端和移动端,使用2套css 代码实现App.vue created: function () { if(document.documentElement.client ...
- solaris下安装oracle 11g与11g rac
1.To Find Swap, RAM, and OS Version 对于 Solaris 操作系统,查看 Swap, RAM, and OS Version 的方法: swap -l /usr/s ...
- Pycharm+Python3+python工程打包成exe+在windows下自动定时运行
python3打包成exe---pyinstaller方法:https://www.cnblogs.com/mufenglin/p/7479281.html 按照如上方式打包后,执行dist文件夹(新 ...
- 理解Shadow DOM(一)
1. 什么是Shadow DOM? Shadow DOM 如果按照英文翻译的话可以理解为 影子DOM, 何为影子DOM呢?可以理解为一般情况下使用肉眼看不到的DOM结构,那如果一般情况下看不到的话,那 ...
- 理论篇-MySQL知识汇总
1. 唯一索引 普通索引允许被索引的数据列包含重复的值.唯一索引则是不允许有重复的值,当然 null 除外,唯一索引不仅仅可以存储 null , 还可以存储多个 null.这么做的好处是: 简化了My ...
- python:unittest之跳过测试和预期失败的用例
在利用单元测试框架执行测试用例的过程中,有时只需要执行一部分用例,或者跳过某些暂不需要执行的用例,python的unittest框架就内置这样的功能. 前面的博客介绍了unittest框架的测试用例加 ...
- There is no action xxxFun defined for api controller api/subitem
在使用abp的框架时,访问某个接口方法出现错误: There is no action xxxFun defined for api controller api/subitem 原因:肯定是访问的接 ...
- EntityFramework Core并发深挖详解,一纸长文,你准备好看完了吗?
前言 之前有关EF并发探讨过几次,但是呢,博主感觉还是有问题,为什么会觉得有问题,其实就是理解不够透彻罢了,于是在项目中都是用的存储过程或者SQL语句来实现,利用放假时间好好补补EF Core并发的问 ...
- OpenResty入门之使用Lua扩展Nginx
记住一点:nginx配置文件很多坑来源自你的空格少了或多了. 1.Centos下载安装 如果你的系统是 Centos 或 RedHat 可以使用以下命令: yum install readline-d ...
- ML.NET 示例:回归之价格预测
写在前面 准备近期将微软的machinelearning-samples翻译成中文,水平有限,如有错漏,请大家多多指正. 如果有朋友对此感兴趣,可以加入我:https://github.com/fei ...