CheckDialog
AlertDialog.Builder builder = new AlertDialog.Builder(CheckDialogActivity.this);
builder.setIcon(R.drawable.ddm)
.setTitle("提示")
.setMessage("是否退出")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(CheckDialogActivity.this, "你点击了确定", Toast.LENGTH_SHORT).show();
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(CheckDialogActivity.this, "你点击了取消", Toast.LENGTH_SHORT).show();
}
}).create()
.show();
PopupWiondow
View popUpWindowView = getLayoutInflater().inflate(R.layout.popup_item,null);
//创建popUpWindow(参数一:自定义的视图,参数二:宽度,参数三:高度,参数四:是否聚焦)
MpopUpWindow = new PopupWindow(popUpWindowView,800,600,true);
//显示位置(参数一:自定义的视图view,参数二:显示的位置,参数三:向X轴偏移的距离,参数四:向Y轴偏移的距离)
//代码动态添加PopUpwinow的背景
MpopUpWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg3));
//显示位置
MpopUpWindow.showAtLocation(popUpWindowView, Gravity.CENTER,0,0);
自定义适配器
public class GridViewAdapter extends BaseAdapter {
private List> list;
private Context context;
public GridViewAdapter(List> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyHolder holder = null;
if (convertView == null) {
holder = new MyHolder();
convertView = View.inflate(context, R.layout.gridview_item, null);
holder.textView = (TextView) convertView.findViewById(R.id.textView);
holder.imageView = (ImageView) convertView.findViewById(R.id.imageview);
convertView.setTag(holder);
} else {
holder = (MyHolder) convertView.getTag();
}
holder.imageView.setImageDrawable(context.getResources().getDrawable((Integer) list.get(position).get("images")));
holder.textView.setText( list.get(position).get("name")+"");
return convertView;
}
class MyHolder {
TextView textView;
ImageView imageView;
}
}
AddViewActivity
//定义适配器(步骤1:写一个类继承自BaseAdapter,实现BaseAdapter中的方法)
MyAdapter adapter = new MyAdapter(list, this);
//将适配器加载到ListView控件上面去
mListView.setAdapter(adapter);
//获取头部视图(GridView)
View view = getLayoutInflater().inflate(R.layout.item_addgridview, null);
//通过视图来获取gridView的实例
GridView mGridView = (GridView) view.findViewById(R.id.gridView2);
//获取展示到GridView上去的数据源
getGridViewData();
//定义适配器
GridViewAdapter GridAdapter = new GridViewAdapter(MGridView_Data,this);
mGridView.setAdapter(GridAdapter);
mListView.addHeaderView(view);
}
进度条
mPrograssBar = (ProgressBar) findViewById(R.id.progressBar_show);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Thread(new Runnable() {
@Override
public void run() {
while (current<=100){
try {
Thread.sleep(500);
current+=5;
runOnUiThread(new Runnable() {
@Override
public void run() {
mPrograssBar.setProgress(current);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
});
子线程改变 runOnUiThread(new Runnable())
seekbar
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
//进度改变(SeekBar本身,参数二:当前进度,参数三:是否来自于用户)
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mTextView.setText(progress+"");
}
//手指接触这个控件的时候调用此方法
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
Toast.makeText(SeekBarActivity.this,"手指按下",Toast.LENGTH_SHORT).show();
}
//手指抬起的时候调用此方法
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
Toast.makeText(SeekBarActivity.this,"手指抬起",Toast.LENGTH_SHORT).show();
}
});
fragment
public class APPFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle
savedInstanceState) {
return View.inflate(getActivity(), R.layout.appfragment, null);
}
}
RatingBar
Fragment
//Fragment的管理者
manager = getFragmentManager();
//获取Fragment事务-------->通过Fragment管理者来获取事务
transaction = manager.beginTransaction();
//事务是用来将容器替换或者添一个Fragment
// transaction.replace(R.id.mLinearLayout,new FragmentA());
transaction.replace(R.id.mLinearLayout,new FragmentA());
//提交事务
transaction.commit();