安卓自己遇到过的问题

来源:互联网 发布:淘宝爆款平台 编辑:程序博客网 时间:2024/04/28 10:32

随笔,大家想看就看,不想看可以离开,不欢迎看了骂人的。

1、子线程传参数传错误,刚开始没有考虑到。

2、刚开始没有审好题,多走了一大步弯路,多建了一个数据库。

3、获取spinner的值出现问题getselectitem

4、Sql语句:"SELECT * FROM intent WHERE Empno='"+id+"'" UPDATE intent SET dddd=? WHEREeee=?  INTERT INTO intent(dd,dd,dd,dd)VALUES(????)

5、获取验证码,把验证码点击获取在线程中获取到传到handler中,再用if语句判定跳转。

6、要多写就多写几个表,多写几个服务,别懒,别想,按着步骤做。

7、有时间再多写个记住密码。

8、分层的时候一定要分好。

9、写登录接口的时候直接把判断是否冻结写上。写注册的时候直接把验证码发过去。

10、           在一个activity里的几个不同按钮点击进入另一个activity里的不同viewpager页面。通过intent发送过去。SetExary,在那边接收到,setItem什么的。

11、           数据库写错了。



编程题

 

Intent intent =newIntent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://192.168.14.198:8080/web/a.jpg"));
startActivity(intent);

intent设置动作;

 

控制Toast显示只显示一次

public staticToasttoast;
public static void
showToast(Context context,Stringcontent){
   
if(toast==null){
       
toast=Toast.makeText(context,content,Toast.LENGTH_SHORT);
   
}else{
       
toast.setText(content);
   
}
   
toast.show();
}

 

 

控制按钮多长时间不能摁

public static longlast;
public static boolean
isClick(){
   
longtime= System.currentTimeMillis();
        if
(time-last<1000){
           
return true;
       
}
       
last=time;
    return false;
}

 

 

欢迎界面停留几秒

timer = new Timer();
task = new TimerTask() {
    @Override
    public void run() {
        b--;
        int c = 0;
        if (b==c){
            Intent intent = newIntent(MainActivity.this,Main2Activity.class);
            startActivity(intent);
        }
    }
};
timer.schedule(task,1000,1000);

 

 

 

正则表达式。只能输入邮箱

String ss = “^[0-9a-zA-Z]+\\@ [0-9a-zA-Z]+\\.[0-9a-zA-Z]+$”;

If(!ss.matchs(ss)){

   One.setText(“你二大爷”);

}

 

网络连接POST传参

String data="name=" + name  + "&age=" + age;

              

      OutputStream       outputStream=connection.getOutputStream();

                    outputStream.write(data.getBytes());

计时器

if(timer==null){
   
timer=newTimer();
   
timerTask=newTimerTask() {
       
@Override
       
public voidrun() {
           
i--;
           
Message message =newMessage();
           
message.obj=i;
           
message.what=200;
           
handler.sendMessage(message);

       
}
    }
;
   
timer.schedule(timerTask,1000,1000);//1000ms执行一次
}

 

sharedPreferences记住账号密码

sharedPreferences=getSharedPreferences("xx",MODE_PRIVATE);
String name=  sharedPreferences.getString("name","");
if
(name!=null&&name!="")
{
   
one.setText(sharedPreferences.getString("name",""));
   
two.setText(sharedPreferences.getString("pwd",""));
   
check.setChecked(true);
}
else
   
check.setChecked(false);


check.setOnCheckedChangeListener(newCompoundButton.OnCheckedChangeListener(){
   
@Override
   
public voidonCheckedChanged(CompoundButtonbuttonView, boolean isChecked) {
        SharedPreferences.Editor editor =getSharedPreferences(
"xx",MODE_PRIVATE).edit();
        if
(check.isChecked()){
            editor.putString(
"name",one.getText().toString());
           
editor.putString("pwd",two.getText().toString());
           
editor.commit();
       
}else{
            editor.remove(
"name");
           
editor.remove("pwd");
       
}
    }
})
;

 

 

欢迎界面只显示一次

 


SharedPreferences sharedPreferences = getSharedPreferences(
"sss",MODE_PRIVATE);
int
xx = sharedPreferences.getInt("key",0);
if
(xx ==0)

{
    SharedPreferences.Editor editor =sharedPreferences.edit()
;
   
editor.putInt("key",1);
   
editor.commit();

 

切换中英文

sta.equals("zh")){
    Locale.setDefault(Locale.
ENGLISH);
   
Configuration configuration = getBaseContext().getResources().getConfiguration();
   
configuration.locale= Locale.ENGLISH;
   
getBaseContext().getResources().updateConfiguration(configuration,getBaseContext().getResources().getDisplayMetrics());
   
recreate();

 

Baseadpter

VieHolder vieholder;
    if
(convertView==null){
        vieholder =
newVieHolder();
       
LayoutInflater flater = LayoutInflater.from(context);
       
convertView = flater.inflate(R.layout.main4a,null);
       
vieholder.bianhao= (TextView) convertView.findViewById(R.id.bianhao);
       
vieholder.xingming= (TextView)convertView.findViewById(R.id.xingming);
       
vieholder.keshi= (TextView)convertView.findViewById(R.id.keshi);
       
vieholder.zhicheng= (TextView)convertView.findViewById(R.id.zhicheng);
       
convertView.setTag(vieholder);
   
}else
      
vieholder= (VieHolder) convertView.getTag();
   
Yi yi =list.get(position);
   
vieholder.bianhao.setText(yi.getId()+"");
   
vieholder.xingming.setText(yi.getName()+"");
   
vieholder.keshi.setText(yi.getTitle()+"");
   
vieholder.zhicheng.setText(yi.getDept()+"");
    return
convertView;
}

public classVieHolder{
   
privateTextViewbianhao,xingming,keshi,zhicheng;
}

 

3. 折线题(重点)柱状图。饼状图

IP地址

6.7阈值

 

获取网络那个

 

 

4. 升序降序 (差不多)

Collections.sort(lst, new CarCompareMore());
if
(!sortFlag)
    Collections.reverse(
lst);

 

6.7阈值

10.排序

11.没有头绪

 

适配器。

 

左滑菜单。

 

Ip

 

DialogEdittext获取值)

finalView layout = View.inflate(context,R.layout.password, null);

final
AlertDialog.Builderbuilder =newAlertDialog.Builder(MainActivity.this);
builder.setTitle("安全支付");
builder.setMessage("支付密码:");
builder.setView(layout);
builder.setNegativeButton("确定",newDialogInterface.OnClickListener() {
   
@Override
   
public voidonClick(DialogInterfacedialog, int which) {
       
/*edit10 = (EditText)builder.findViewById(R.id.edit10);*/
       
edit10=(EditText)layout.findViewById(R.id.edit10);
       
String zhu =edit10.getText().toString();
      
// int jag = Integer.valueOf(zhu);
       
if(zhu.equals("123456")){
            Toast.makeText(
context,"密码输入正确",Toast.LENGTH_SHORT).show();
           
String uri="http://192.168.14.196:8080/MyWeb/SetCarAccountRechargeServlet";
            new
MyThread2(uri, edit.getText().toString(), edit2.getText().toString(),context,handler).start();
       
}else{
            Toast.makeText(
context,"密码输入错误,请重新输入",Toast.LENGTH_SHORT).show();
       
}
    }
})
;
builder.show();

 

自动手动控制

 

比较值的大小 equals

 

比较时间

public classCarCompareMoreimplementsComparator<CarAccountRecharge>{

SimpleDateFormatsdf =  newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   
Calendar calendar=Calendar.getInstance();
   
Calendar calendar1=Calendar.getInstance();
    try
{
        calendar.setTime(sdf.parse(o1.getDate()) )
;
       
calendar1.setTime( sdf.parse(o2.getDate()) );
   
}catch(ParseException e) {
        e.printStackTrace()
;
   
}

   
if( calendar.compareTo(calendar1)>0)
       
return 1;
    else
        return 
0;
}

 

 

服务器

 

防误触

Private long startTime = 0

@Override
public voidonBackPressed() {
   
longcurrentTime= System.currentTimeMillis();
    if
(currentTime -startTime>=3000){
        Toast.makeText(
context,"再按一次退出",Toast.LENGTH_SHORT).show();
       
startTime=currentTime;
   
}else{
        finish()
;
   
}

 

 

 

 

获取当前时间

SimpleDateFormat sf=newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date currdate =newDate(System.currentTimeMillis());
String str = sf.format(currdate);

 

 

慢慢显示

Animation animation= AnimationUtils.loadAnimation(context,R.anim.list_anim);
LayoutAnimationController con =newLayoutAnimationController(animation);
con.setDelay(0.5f);
con.setOrder(LayoutAnimationController.ORDER_NORMAL);
listView.setLayoutAnimation(con);

 

 

 

半透明

AlertDialog dialog= builder.show();
Window window = dialog.getWindow();
WindowManager.LayoutParams layoutParams= window.getAttributes();
layoutParams.alpha=0.5f;
window.setAttributes(layoutParams);

 

 

Edittext只显示一行

android:singleLine="false"

 

SimpleAdaper BaseAdaper

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 橡木床好吗 家具木床 紫檀木床 小木床 什么木床好 木床设计图 普通木床 高低木床 象木床 白木床 上下木床 木床图 上下层木床 木床咯吱咯吱响怎么办 香樟木床价格 上下木床价格及图片 红木床多少钱 1.8米木床设计图 橡木床好还是松木床好 自制木床结构图 自制木床设计图 木床品牌排行榜 榆木床好不好 摇椅 单人床图片 床的价格及图片 床的图片和价格 实木家具床品牌 榻榻米实木床 实木床品牌排行榜 幼儿园实木家具 实木床 双人床 特价 实木床多少钱一张 原木沙发床 松木双人床 为什么不能睡红木床 紫什么木 木府 木府旅游 木府风云全集50集播放 木府风云主题曲