Beispiel #1
0
 // 刷新图片
 @Override
 public void onResume() {
   super.onResume();
   if (!TextUtils.isEmpty(pathImage)) {
     Bitmap addbmp = BitmapFactory.decodeFile(pathImage);
     HashMap<String, Object> map = new HashMap<String, Object>();
     map.put("itemImage", addbmp);
     imageItem.add(map);
     simpleAdapter =
         new SimpleAdapter(
             getActivity(),
             imageItem,
             R.layout.item_upload_image_grid,
             new String[] {"itemImage"},
             new int[] {R.id.imageView1});
     simpleAdapter.setViewBinder(
         new SimpleAdapter.ViewBinder() {
           @Override
           public boolean setViewValue(View view, Object data, String textRepresentation) {
             // TODO Auto-generated method stub
             if (view instanceof ImageView && data instanceof Bitmap) {
               ImageView i = (ImageView) view;
               i.setImageBitmap((Bitmap) data);
               return true;
             }
             return false;
           }
         });
     mGridView.setAdapter(simpleAdapter);
     simpleAdapter.notifyDataSetChanged();
     // 刷新后释放防止手机休眠后自动添加
     pathImage = null;
   }
 }
Beispiel #2
0
  private void ReloadChapterList() {

    String chapterlist[] = getResources().getStringArray(R.array.chapterlist);

    String chapter[] = Common.tokenFn("-1," + chapterlist[mBook], ",");

    ArrayList<HashMap<String, String>> mList = new ArrayList<HashMap<String, String>>();

    for (int y = 0; y < chapter.length; y++) {
      HashMap<String, String> item = new HashMap<String, String>();

      if (y == 0) {
        item.put("Chapter", "ALL");
      } else {
        item.put("Chapter", chapter[y]);
      }

      mList.add(item);
    }

    SimpleAdapter adapter =
        new SimpleAdapter(
            getBaseContext(),
            mList,
            android.R.layout.simple_spinner_item,
            new String[] {"Chapter"},
            new int[] {android.R.id.text1});
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    Spinner chapter_spinner = (Spinner) findViewById(R.id.chapters);
    chapter_spinner.setAdapter(adapter);

    mChapter = 0;
    chapter_spinner.setSelection(mChapter);
    ReloadBibleContents();
  }
  /** 处理资讯 */
  private void dealNews() {
    SimpleAdapter listItemAdapter =
        new SimpleAdapter(
            this.getActivity(),
            newsList,
            R.layout.listitem_news,
            new String[] {"photo", "title", "publisher", "date"},
            new int[] {
              R.id.news_image_photo,
              R.id.news_label_title,
              R.id.news_label_publisher,
              R.id.news_label_date
            });
    listItemAdapter.setViewBinder(
        new ViewBinder() {
          public boolean setViewValue(View view, Object data, String textRepresentation) {
            if (view instanceof ImageView && data instanceof Bitmap) {
              ImageView imageView = (ImageView) view;
              Bitmap bitmap = (Bitmap) data;
              imageView.setImageDrawable(new BitmapDrawable(bitmap));
              return true;
            }
            return false;
          }
        });
    listNews.setAdapter(listItemAdapter);
    listNews.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View v, int index, long arg3) {
            index = index - 1;
            HashMap<String, Object> newsMap = newsList.get(index);
            Intent intent = new Intent(HomeActivity.this.getActivity(), BrowserActivity.class);
            intent.putExtra("url", newsMap.get("url").toString());
            HomeActivity.this.startActivity(intent);
          }
        });
    listNews.setOnScrollListener(
        new OnScrollListener() {
          boolean isLastRow = false;

          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (isLastRow && scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
              loadNews();
              isLastRow = false;
            }
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (firstVisibleItem + visibleItemCount == totalItemCount && totalItemCount > 2) {
              isLastRow = true;
            }
          }
        });
  }
  @Override
  protected void onResume() {
    super.onResume();
    // DatabaseOpenHelperを取得
    DatabaseOpenHelper databaseOpenHelper = new DatabaseOpenHelper(this);

    SQLiteDatabase database = null;
    Cursor cursor = null;

    try {
      // 読み取り専用でSQLiteDatabaseを取得
      database = databaseOpenHelper.getWritableDatabase();
      // databaseOpenHelper.onCreate(database);
      // databaseOpenHelper.onInsert(database);
      ArrayList<HashMap<String, Object>> outputArray = new ArrayList<HashMap<String, Object>>();
      HashMap<String, Object> item = null;
      // クエリーを投げて、検索して取得結果のカーソルを取得
      cursor = database.query("MIMICRY", null, null, null, null, null, null);

      startManagingCursor(cursor);

      int i = 0;
      while (cursor.moveToNext()) {

        item = new HashMap<String, Object>();
        item.put("img", Constant.images[i]);
        item.put("title", cursor.getString(cursor.getColumnIndex("TITLE")));
        item.put("challenge", cursor.getString(cursor.getColumnIndex("CHALLENGE_LEVEL")));
        item.put("rating", cursor.getString(cursor.getColumnIndex("RATING")));
        outputArray.add(item);
        i++;
      }
      SimpleAdapter myAdapter =
          new SimpleAdapter(
              this,
              outputArray,
              R.layout.mimicry_row, // ここがポイント2
              new String[] {"img", "title", "challenge", "rating"}, // ここがポイント3-1
              new int[] {
                R.id.imageView, R.id.rowtitle, R.id.change_level, R.id.rating
              } // ここがポイント3-2
              );

      setListAdapter(myAdapter);
      myAdapter.notifyDataSetChanged();

      setSelection(ps);

    } finally {
      if (database != null) {
        database.close();
        Log.v("RssListActivity", "Succeeded in close the database.");
      }
    }
  }
  private void bindFileToFileListView(String selectDir)
      throws IllegalArgumentException, SecurityException, IllegalAccessException,
          NoSuchFieldException {
    if (selectDir.equals("")) selectDir = "/";
    this.currDir = selectDir;
    this.fileNav.setText(this.currDir);
    File dir = new File(this.currDir);
    File[] files = dir.listFiles();
    List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
    if (files != null)
      for (File f : files) {
        String name = f.getName();
        Map<String, Object> map = new HashMap<String, Object>();
        if (f.isDirectory()) {
          map.put(FILE_PIC, this.getImageResourceByFileExt(""));
          map.put(FILE_FULL_PATH, f.getAbsolutePath());
        } else {
          int p = name.lastIndexOf(".");
          if (p > 0) {
            map.put(FILE_PIC, this.getImageResourceByFileExt(name.substring(p + 1).toLowerCase()));
          } else map.put(FILE_PIC, this.unknowFile);

          StringBuilder sb = new StringBuilder(String.valueOf(f.length() / 1024));
          sb.append("KB ");
          sb.append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(f.lastModified())));
          map.put(FILE_FULL_PATH, sb.toString());
        }
        map.put(FILE_NAME, name);

        data.add(map);
      }
    else data.add(new HashMap<String, Object>());

    SimpleAdapter adp =
        new SimpleAdapter(
            this.getContext(),
            data,
            R.layout.file_list_view,
            new String[] {FILE_PIC, FILE_NAME, FILE_FULL_PATH},
            new int[] {R.id.file_pic, R.id.file_name, R.id.file_full_path});
    adp.setViewBinder(
        new ViewBinder() {
          public boolean setViewValue(View view, Object data, String textRepresentation) {
            if (view instanceof ImageView && data instanceof Integer) {
              ImageView img = (ImageView) view;
              img.setImageResource(Integer.parseInt(data.toString()));
              return true;
            }
            return false;
          }
        });
    this.fileList.setAdapter(adp);
  }
 @Override
 public void trackChanged(MPDStatus mpdStatus, int oldTrack) {
   if (isPlayQueue) {
     // Mark running track...
     for (HashMap<String, Object> song : songlist) {
       if (((Integer) song.get("songid")).intValue() == mpdStatus.getSongId())
         song.put("play", android.R.drawable.ic_media_play);
       else song.put("play", 0);
     }
     final SimpleAdapter adapter = (SimpleAdapter) getListAdapter();
     if (adapter != null) adapter.notifyDataSetChanged();
   }
 }
 /**
  * 点击底部按钮
  *
  * @param v
  */
 public void onClick(View v) {
   Log.d("debug", "isLastRow -->> " + isLastRow);
   if (adapter.getCount() < totalCount) { // 当前加载的数据条数小于总条数
     // 加载更多分页的课程成绩信息
     dlg.loadMoreData(adapter.getCount());
     // 进度条可见,按钮不可见
     pbFoot.setVisibility(View.VISIBLE);
     btnFoot.setVisibility(View.GONE);
     isLastRow = false;
   } else if (isLastRow) { // 所有的条目已经和最大条数相等,则移除底部的View,弹出提示信息
     lvCourseScore.removeFooterView(listfoot);
     Toast.makeText(ac, R.string.complete_loading_all_data, Toast.LENGTH_SHORT).show();
   }
 }
 @Override
 protected void onPostExecute(List<Map<String, String>> mapping) {
   super.onPostExecute(mapping);
   SimpleAdapter adapter =
       new SimpleAdapter(
           activity,
           mapping,
           android.R.layout.simple_list_item_1,
           new String[] {"Name"},
           new int[] {android.R.id.text1});
   activity.mState.mapping = mapping;
   activity.setListAdapter(adapter);
   adapter.notifyDataSetChanged();
   activity.stopProgressDialog();
 }
Beispiel #9
0
  @Override
  public void callBack(String TAG, String str) {
    // TODO 自動生成されたメソッド・スタブ

    JSONArray json;
    try {
      json = new JSONArray(str);
      data.clear();
      for (int i = 0; i < json.length(); i++) {
        JSONObject plan = json.getJSONObject(i).getJSONObject("plan");

        // 一行の複数項目を HashMap で詰め込む
        map = new HashMap<String, String>();
        map.put("member_id", plan.getString("member_id"));
        map.put("plan_id", plan.getString("plan_id"));
        map.put("plan_name", "プラン名:" + plan.getString("plan_name"));

        JSONArray categories = plan.getJSONArray("plan_categories");
        String cate = "カテゴリ:";
        for (int j = 0; j < categories.length(); j++) {
          JSONObject categ = (JSONObject) categories.get(j);
          cate = cate + " " + categ.getString("category_id");
        }

        map.put("categories", cate);
        data.add(map);
      }
      adapter.notifyDataSetChanged();
    } catch (JSONException e) {
      // TODO 自動生成された catch ブロック
      e.printStackTrace();
    }
  }
  private void showDirectoryContentsUI() {
    // Fijamos el directorio actual.

    iCurrentPath = iLoadingPathname;

    // Visualizamos el nombre del directorio actual.

    iFolderNameText.setText(iCurrentPath + "/");

    // Eliminamos la lista de ficheros antiguos.

    iFilesList.clear();

    // Si no estamos en el directorio raíz, añadimos como primer elemento
    // ir al directorio anterior.

    if (!iCurrentPath.equals("")) {
      iFilesList.add(
          createListViewItem(getResources().getString(R.string.folder_up), R.drawable.folder_up));
    }

    // Inicializamos la lista de ficheros.

    for (MyFile child : iChilds)
      iFilesList.add(
          createListViewItem(
              child.getName(), child.isDirectory() ? R.drawable.folder : R.drawable.file));

    // Visualizamos la lista.

    iAdapterList.notifyDataSetChanged();
    iListView.setAdapter(iAdapterList);
  }
  /**
   * fills the list with stops from the local database
   *
   * @param db the database adapter to use
   */
  private void fillList(BusDbAdapter db) {
    Cursor c;
    if (listType == FAVORITES) {
      c = db.getFavoriteDest(NUM_ENTRIES_TO_FETCH);
    } else { // listType == MAJOR
      c = db.getMajorDest(NUM_ENTRIES_TO_FETCH);
    }
    int stopIDIndex = c.getColumnIndex("stop_id");
    int stopDescIndex = c.getColumnIndex("stop_desc");
    int routeIDIndex = c.getColumnIndex("route_id");
    int routeDescIndex = c.getColumnIndex("route_desc");
    if (c != null) {
      for (int i = 0; i < c.getCount(); i++) {
        HashMap<String, String> item = new HashMap<String, String>();

        String stopID = c.getString(stopIDIndex);
        String stopName = c.getString(stopDescIndex);
        String route = c.getString(routeIDIndex);
        String routeDesc = c.getString(routeDescIndex);
        Log.v(TAG, "PUT");
        Log.v(TAG, "stopID " + stopID + " stopName " + stopName);
        Log.v(TAG, "routeID " + route + " routeDesc" + routeDesc);
        item.put("stopID", stopID);
        item.put("stopName", stopName);
        item.put("routeID", route);
        item.put("routeDesc", routeDesc);
        c.moveToNext();
        locationList.add(item);
      }
      listAdapter.notifyDataSetChanged();
    }
  }
  /** 初始化资源 */
  void initreso() {
    al_demandobject = new ArrayList<>();
    arrayList_map = new ArrayList<>();
    simpleAdapter =
        new SimpleAdapter(
            view.getContext(),
            arrayList_map,
            R.layout.demanditem,
            new String[] {"goodname", "picture", "descreption", "time"},
            new int[] {
              R.id.goods_name, R.id.demand_touxiang, R.id.goods_description, R.id.release_time
            });
    listView.setAdapter(simpleAdapter);

    simpleAdapter.setViewBinder(
        new SimpleAdapter.ViewBinder() {
          @Override
          public boolean setViewValue(View view, Object data, String textRepresentation) {

            if (view instanceof ImageView && data instanceof Bitmap) {
              ImageView iv = (ImageView) view;
              // iv.setImageBitmap((Bitmap) data);
              iv.setImageDrawable(new CircleImageDrawable((Bitmap) data));
              return true;
            } else {
              return false;
            }
          }
        });
  }
Beispiel #13
0
  public static void clearAllData() {

    listArtSelClp.clear();
    adapterListArtClp.notifyDataSetChanged();

    globalDepozSel = "";
    globalCodDepartSelectetItem = "";
    CreareClp.codClient = " ";
    CreareClp.codJudet = " ";
    CreareClp.oras = " ";
    CreareClp.strada = " ";
    CreareClp.persCont = " ";
    CreareClp.telefon = " ";
    CreareClp.codFilialaDest = " ";
    CreareClp.comandaFinala = " ";
    CreareClp.dataLivrare = " ";
    CreareClp.tipTransport = "TRAP";
    CreareClp.tipPlata = "B";

    CLPFragment1.clearClientData();

    for (int i = 0; i < objArticol.length; i++) {
      objArticol[i] = null;
    }

    slidingDrawerSaveClp.close();
    textValoareGreutate.setText("");
    textTotalGreutate.setText("");
  }
  @Override
  @SuppressWarnings("unchecked")
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
      Log.e(THIS_FILE, "bad menuInfo", e);
      return false;
    }

    HashMap<String, Object> codec = null;
    codec = (HashMap<String, Object>) mAdapter.getItem(info.position);

    if (codec == null) {
      // If for some reason the requested item isn't available, do nothing
      return false;
    }
    int selId = item.getItemId();
    if (selId == MENU_ITEM_ACTIVATE) {
      boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
      userActivateCodec(codec, isDisabled);
      return true;
    }
    return false;
  }
 private void updateList() {
   mCardsAdapter.notifyDataSetChanged();
   int count = mCards.size();
   setTitle(
       getResources()
           .getQuantityString(
               R.plurals.card_browser_title, count, mDeck.getDeckName(), count, mAllCards.size()));
 }
 private void updateList() {
   mCardsAdapter.notifyDataSetChanged();
   int count = mCards.size();
   UIUtils.setActionBarSubtitle(
       this,
       getResources()
           .getQuantityString(R.plurals.card_browser_subtitle, count, count, mAllCards.size()));
 }
 @Override
 public void onRefresh() {
   a = 34;
   data.clear();
   data = getdata();
   simpleAdapter.notifyDataSetChanged();
   swipeRefreshLayout.setRefreshing(false);
 }
  private void populateItem() {

    SimpleAdapter.ViewBinder viewBinder =
        new SimpleAdapter.ViewBinder() {

          public boolean setViewValue(View view, Object data, String textRepresentation) {
            // We configured the SimpleAdapter to create TextViews (see
            // the 'to' array, above), so this cast should be safe:
            TextView textView = (TextView) view;
            textView.setText(textRepresentation);
            return true;
          }
        };

    SimpleAdapter seasonAdapter =
        new SimpleAdapter(
            this,
            seasonList,
            android.R.layout.simple_spinner_item,
            new String[] {"seasonName"},
            new int[] {android.R.id.text1});
    seasonAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    seasonAdapter.setViewBinder(viewBinder);
    spnSeason.setAdapter(seasonAdapter);
    spnSeason.setPrompt(getString(R.string.select_season));

    SimpleAdapter typeAdapter =
        new SimpleAdapter(
            this,
            typeList,
            android.R.layout.simple_spinner_item,
            new String[] {"typeName"},
            new int[] {android.R.id.text1});
    typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    typeAdapter.setViewBinder(viewBinder);
    spnType.setAdapter(typeAdapter);
    spnType.setPrompt(getString(R.string.select_type));

    SimpleAdapter statusAdapter =
        new SimpleAdapter(
            this,
            statusList,
            android.R.layout.simple_spinner_item,
            new String[] {"statusName"},
            new int[] {android.R.id.text1});
    statusAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    statusAdapter.setViewBinder(viewBinder);
    spnStatus.setAdapter(statusAdapter);
    spnStatus.setPrompt(getString(R.string.select_status));
  }
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   String codecName = (String) buttonView.getTag();
   if (codecName != null) {
     HashMap<String, Object> codec = null;
     for (int i = 0; i < mAdapter.getCount(); i++) {
       @SuppressWarnings("unchecked")
       HashMap<String, Object> tCodec = (HashMap<String, Object>) mAdapter.getItem(i);
       if (codecName.equalsIgnoreCase((String) tCodec.get(CODEC_NAME))) {
         codec = tCodec;
         break;
       }
     }
     if (codec != null) {
       userActivateCodec(codec, isChecked);
     }
   }
 }
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case 100:
       adapter.notifyDataSetChanged();
       mRestoreList.onRefreshFinish();
       break;
   }
   super.handleMessage(msg);
 }
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   switch (msg.what) {
     case DATACHANGED:
       progressDialog.dismiss();
       simpleAdapter.notifyDataSetChanged();
   }
 }
 /**
  * 显示更多加载的数据
  *
  * @param moreData
  */
 public void printMoreData(List<HashMap<String, String>> moreData) {
   data.addAll(moreData);
   // 刷新数据
   adapter.notifyDataSetChanged();
   // 按钮可见
   btnFoot.setVisibility(View.VISIBLE);
   // 进度不可见
   pbFoot.setVisibility(View.GONE);
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.trackdetail_menu_save:
        String enteredName = etName.getText().toString().trim();
        if ((enteredName.length() > 0) && (!enteredName.equals(trackNameInDB))) {
          DataHelper.setTrackName(trackId, enteredName, getContentResolver());
        }

        // All done
        finish();
        break;
      case R.id.trackdetail_menu_cancel:
        finish();
        break;
      case R.id.trackdetail_menu_display:
        Intent i;
        boolean useOpenStreetMapBackground =
            PreferenceManager.getDefaultSharedPreferences(this)
                .getBoolean(
                    OSMTracker.Preferences.KEY_UI_DISPLAYTRACK_OSM,
                    OSMTracker.Preferences.VAL_UI_DISPLAYTRACK_OSM);
        if (useOpenStreetMapBackground) {
          i = new Intent(this, DisplayTrackMap.class);
        } else {
          i = new Intent(this, DisplayTrack.class);
        }
        i.putExtra(Schema.COL_TRACK_ID, trackId);
        startActivity(i);
        break;
      case R.id.trackdetail_menu_export:
        new ExportTrackTask(this, trackId).execute();
        // Pick last list item (Exported date) and update it
        SimpleAdapter adapter = ((SimpleAdapter) lv.getAdapter());
        @SuppressWarnings("unchecked")
        Map<String, String> data = (Map<String, String>) adapter.getItem(adapter.getCount() - 1);
        data.put(
            ITEM_VALUE,
            DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis())));
        adapter.notifyDataSetChanged();
        break;
    }
    return super.onOptionsItemSelected(item);
  }
 /*
  * Updates the ListView according to the observers.
  */
 private void updateList() {
   TransferObserver observer = null;
   HashMap<String, Object> map = null;
   for (int i = 0; i < observers.size(); i++) {
     observer = observers.get(i);
     map = transferRecordMaps.get(i);
     Util.fillMap(map, observer, i == checkedIndex);
   }
   simpleAdapter.notifyDataSetChanged();
 }
Beispiel #25
0
  private void loadMoreData() {

    count = adapter.getCount();
    for (int i = count; i < count + 5; i++) {
      HashMap<String, String> map = new HashMap<String, String>();
      map.put("itemText", "测试数据" + i);
      listData.add(map);
    }
    count = listData.size();
  }
    /**
     * Creates ListAdapter populated with offer information.
     *
     * @param offers the list of offers used to populate the adapter.
     * @return an adapter populated with offer information.
     */
    private ListAdapter createOfferListAdapter(List<Offer> offers) {
      List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
      for (Offer offer : offers) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("offerIcon", offer.getImageUrl());
        map.put("offerTitle", offer.getTitle());
        map.put("offerDetails", offer.getDescription());
        data.add(map);
      }

      SimpleAdapter adapter =
          new SimpleAdapter(
              PlaceDetailsActivity.this,
              data,
              R.layout.offer_item,
              new String[] {"offerIcon", "offerTitle", "offerDetails"},
              new int[] {R.id.offer_Image, R.id.offer_name, R.id.offer_description});
      adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
      return adapter;
    }
    /**
     * Creates ListAdapter populated with recommendation information.
     *
     * @param recommendations the list of recommendations used to populate the adapter.
     * @return an adapter populated with recommendation information.
     */
    private ListAdapter createRecommendationsListAdapter(List<Recommendation> recommendations) {
      List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
      for (Recommendation recommendation : recommendations) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("productImage", recommendation.getImageUrl());
        map.put("recommendationTitle", recommendation.getTitle());
        map.put("recommendationDetails", recommendation.getDescription());
        data.add(map);
      }

      SimpleAdapter adapter =
          new SimpleAdapter(
              PlaceDetailsActivity.this,
              data,
              R.layout.offer_item,
              new String[] {"productImage", "recommendationTitle", "recommendationDetails"},
              new int[] {R.id.offer_Image, R.id.offer_name, R.id.offer_description});
      adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
      return adapter;
    }
Beispiel #28
0
  private void loadData() {

    for (int i = 0; i < titles.length; i++) {
      Map<String, String> map = new HashMap<>();
      map.put("title", titles[i]);
      map.put("clazz", classNames[i]);
      data.add(map);
    }

    adapter.notifyDataSetChanged();
  }
Beispiel #29
0
 @Override
 protected void buildListAdapter(Object[] result) {
   // TODO Auto-generated method stub
   if (result.length == 0)
     Toast.makeText(this, R.string.error_device_code_is_not_existed, Toast.LENGTH_LONG).show();
   ArrayList<HashMap<String, Device>> items = new ArrayList<HashMap<String, Device>>();
   for (int i = 0; i < result.length; i++) {
     HashMap<String, Device> item = new HashMap<String, Device>();
     item.put("device", (Device) result[i]);
     items.add(item);
   }
   SimpleAdapter adapter =
       new SimpleAdapter(
           this,
           items,
           android.R.layout.simple_list_item_checked,
           new String[] {"device"},
           new int[] {android.R.id.text1});
   adapter.setViewBinder(this);
   setListAdapter(adapter);
 }
Beispiel #30
0
 @Override
 public void handleMessage(Message msg) {
   if (msg.what != REFRESH_LOCAL_USERS) {
     users.clear();
     for (NetUser netUser : communication.getNetUserList().userListToArray()) {
       HashMap<String, String> userMap = new HashMap<String, String>();
       userMap.put(USERNAME, netUser.getName());
       userMap.put(IP, netUser.getIp().getHostAddress());
       users.add(userMap);
     }
     adapter.notifyDataSetChanged();
   }
 }