示例#1
0
 @Override
 public View getView(int position, View view, ViewGroup parent) {
   ViewHolder holder;
   if (view == null) {
     view = LayoutInflater.from(getContext()).inflate(R.layout.list_item_server, parent, false);
     holder = new ViewHolder();
     holder.name = (TextView) view.findViewById(R.id.lblDeviceName);
     holder.details = (TextView) view.findViewById(R.id.lblDeviceDetail);
     view.setTag(holder);
   } else {
     holder = (ViewHolder) view.getTag();
   }
   NsdServiceInfo serviceInfo = getItem(position);
   holder.name.setText(serviceInfo.getServiceName());
   holder.details.setText(serviceInfo.getHost().toString());
   return view;
 }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   final NsdServiceInfo item = mNsdList.get(position);
   if (v == null) {
     LayoutInflater li =
         (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = li.inflate(R.layout.generic_list_item, null);
   }
   if (item != null) {
     TextView textView = (TextView) v;
     if (textView != null) {
       textView.setText(item.getServiceName().replace("-", " - "));
       textView.setOnClickListener(
           new OnClickListener() {
             public void onClick(View v) {
               updatePd40DeviceIp(item);
             }
           });
     }
   }
   return v;
 }