1、调用VitamioBundle播放窗口

                Intent intent = new Intent(getApplicationContext(), VideoActivity.class);
intent.setData(Uri.parse(path));
// intent.putExtra("path", f.path);
intent.putExtra("displayName", "企建教育");
startActivity(intent);

2、AndBase对话框

                AbDialogUtil.showAlertDialog(MainActivity.this, "这里是标题",
"这里写一些描述", new AbDialogOnClickListener() { @Override
public void onPositiveClick() {
// TODO Auto-generated method stub } @Override
public void onNegativeClick() {
// TODO Auto-generated method stub }
});

3、AndBase框架异步获取json数据,并解析的过程

        mAbHttpUtil = AbHttpUtil.getInstance(this);
mAbHttpUtil.setTimeout(10000);
String urlString = "http://ke.cpmqa.com/";
mAbHttpUtil.get(urlString, new AbStringHttpResponseListener() { @Override
public void onSuccess(int statusCode, String content) {
Log.d(TAG, "onSuccess"); try {
JSONObject jsonObject = new JSONObject(content); int total = jsonObject.getInt("total");
Boolean success = jsonObject.getBoolean("success");
Log.d(TAG, "total:" + total + " | success:" + success); JSONArray jsonArray = jsonObject.getJSONArray("rows");// 里面有一个数组数据,可以用getJSONArray获取数组
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject item = jsonArray.getJSONObject(i); // 得到每个对象 TttVideo t = new TttVideo();
t.Id = item.getInt("Id");
t.VideoName = item.getString("VideoName");
t.Flag = item.getInt("Flag");
t.VideoUrl = item.getString("VideoUrl");
t.OrderFlag = item.getInt("OrderFlag"); list.add(t); } } catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} } // 失败,调用
@Override
public void onFailure(int statusCode, String content,
Throwable error) { Log.d(TAG, "onFailure");
AbToastUtil.showToast(MainActivity.this, error.getMessage());
} // 开始执行前
@Override
public void onStart() {
Log.d(TAG, "onStart");
// 显示进度框
AbDialogUtil
.showProgressDialog(MainActivity.this, 0, "正在查询...");
} // 完成后调用,失败,成功
@Override
public void onFinish() {
Log.d(TAG, "onFinish");
// 移除进度框
AbDialogUtil.removeDialog(MainActivity.this);
}; });

4、动态添加控件,并设置控件属性

                TableLayout table1 = (TableLayout) findViewById(R.id.table1);

                if (list != null) {
for (TttVideo t : list) { TextView tv = new TextView(MainActivity.this);
tv.setId(t.Id);
tv.setText(Html.fromHtml(t.VideoName)); TableRow.LayoutParams lp = new TableRow.LayoutParams(
TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.WRAP_CONTENT); if (t.Flag == 0) {
lp.setMargins(
DensityUtil.dip2px(MainActivity.this, 20),
DensityUtil.dip2px(MainActivity.this, 20),
DensityUtil.dip2px(MainActivity.this, 15),
DensityUtil.dip2px(MainActivity.this, 20));
tv.setTextColor(Color.BLACK);
} else {
lp.setMargins(
DensityUtil.dip2px(MainActivity.this, 40),
DensityUtil.dip2px(MainActivity.this, 15),
DensityUtil.dip2px(MainActivity.this, 15),
DensityUtil.dip2px(MainActivity.this, 15)); if (MediaUtils.isVideo(t.VideoUrl)) {
tv.setTextColor(Color.rgb(53, 53, 53)); } tv.setOnClickListener(MainActivity.this); } TableRow tr = new TableRow(MainActivity.this);
tr.addView(tv, lp); if (t.Flag == 0) { } else {
tr.setBackgroundColor(Color.WHITE);
} TableLayout.LayoutParams tablelp = new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT); tablelp.setMargins(0, 0, 0,
DensityUtil.dip2px(MainActivity.this, 1)); table1.addView(tr, tablelp); } }

5、代码中的单位转换类:

public class DensityUtil {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
} /**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
}
05-11 13:20