兼容4.0的有:
android 4.0 联网在子线程
Java联网方式: httpURLConnection
Android联网方式:封装了 HttpClient
image.png image.png
sqlite 继承 SQLiteOpenHelper
sql表达式: 自己写的sql语句
2. 封装的sql语句,execsql
查询:rawquery
bitmap:位图
oom:out of memory 内存溢出:加载图片时
从 sd卡转移到内存中
防止内存溢出:1.压缩图片
在清单文件中添加 联网,读写权限,
image.png
image.png
自己定义一个类 继承Application
视图:
我们使用 xUtils 加载布局,件查找ID ,通过event绑定视图添加监听
MainActivity 中代码:
···
package com.example.myxutil;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.x;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
@ContentView(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {
//通过注解查找控件
@InjectView(R.id.button)
Button button;
@InjectView(R.id.button2)
Button button2;
@InjectView(R.id.textView)
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// ButterKnife.inject(this);
//让Activity识别注解
x.view().inject(this);
}
//绑定短按监听 type可以省略
@Event(type = View.OnClickListener.class,value = R.id.button)
private void MyShot(View v){
Toast.makeText(this, "111", Toast.LENGTH_SHORT).show();
}
@Event(type = View.OnLongClickListener.class,value = R.id.button)
private boolean MyLong1(View v){
Toast.makeText(this, "2222", Toast.LENGTH_SHORT).show();
return true;
}
@Event(type = View.OnLongClickListener.class,value = R.id.button2)
private boolean MyLong(View v){
Toast.makeText(this, "222222", Toast.LENGTH_SHORT).show();
return true;
}
}
···
网友评论