Exemple #1
0
 public void handleMessage(android.os.Message msg) {
   if (msg.what == 1000) {
     ChatMessage from = (ChatMessage) msg.obj;
     cmList.add(from);
     dbUtiles.insert(from);
     mAdapter.notifyDataSetChanged();
     lv.setSelection(cmList.size() - 1);
   }
   if (msg.what == 100) {
     mAdapter.notifyDataSetChanged();
     lv.setSelection(cmList.size() - 1);
   }
   if (msg.what == 10) {
     mAdapter.notifyDataSetChanged();
     lv.setSelection(cmList.size() - 1);
     //				mAdapter.changeFirstItem(str);
     ChatMessage cm1 =
         new ChatMessage(
             1,
             "您还记得大明湖畔的"
                 + robotName
                 + "吗?就是我喽,"
                 + "人称江湖百晓生,熟知段子、新闻、天气、列车、菜谱、航班、百度百科,很高兴为您服务!");
     cm1.setListType(0);
     cmList.add(cm1);
     dbUtiles.insert(cm1);
     handler.sendEmptyMessage(100);
   }
 };
Exemple #2
0
 @Override
 protected void onRestart() {
   mAdapter.notifyDataSetChanged();
   // 关闭软键盘
   InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
   // 得到InputMethodManager的实例
   if (imm.isActive()) {
     // 如果开启
     imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
     // 关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的
   }
   robotName = MyApplication.getString(HttpUtils.ROBOT_NIKE_NAME, "小黄鸭");
   title.setText(robotName);
   str = "您还记得大明湖畔的" + robotName + "吗?就是我喽," + "人称江湖百晓生,熟知段子、新闻、天气、列车、菜谱、航班、百度百科,很高兴为您服务!";
   mAdapter.changeFirstItem(str);
   super.onRestart();
 }