コード例 #1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    if (convertView == null) {
      convertView = inflater.inflate(R.layout.column_row, null);
    }

    Details details = getItem(position);

    ((TextView) convertView.findViewById(R.id.ssid))
        .setText(
            (TextUtils.isEmpty(details.getSSID()) ? "HIDDEN" : details.getSSID())
                + " ("
                + details.getBSSID()
                + ")");

    Strength strength = details.getWifiLevel();

    ImageView imageView = (ImageView) convertView.findViewById(R.id.levelImage);
    imageView.setImageResource(strength.getImageResource());

    ImageView securityImage = (ImageView) convertView.findViewById(R.id.securityImage);
    securityImage.setImageResource(details.getSecurity().getImageResource());

    TextView textLevel = (TextView) convertView.findViewById(R.id.level);
    textLevel.setText(details.getLevel() + "dBm");
    textLevel.setTextColor(getContext().getResources().getColor(strength.getColorResource()));

    ((TextView) convertView.findViewById(R.id.channel)).setText("" + details.getChannel());
    ((TextView) convertView.findViewById(R.id.frequency))
        .setText(" (" + details.getFrequency().getBand() + ")");
    ((TextView) convertView.findViewById(R.id.security))
        .setText(securitiesAsString(details.getSecurities()));

    return convertView;
  }