@Override
  public View getChildView(
      int groupPosition,
      final int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {

    final String childText = (String) getChild(groupPosition, childPosition);

    if (convertView == null) {
      LayoutInflater infalInflater =
          (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = infalInflater.inflate(R.layout.list_item, null);
      convertView.setClickable(false);
    }

    TextView txtListChild = (TextView) convertView.findViewById(R.id.lblListItem);
    // String uri = "@drawable/ic_perm_scan_wifi_white.png";
    ButtonFloat imageView = (ButtonFloat) convertView.findViewById(R.id.img);
    if (childPosition == 0) { // ID
      imageView.setDrawableIcon(_context.getResources().getDrawable(R.drawable.identity_theft));
    } else if (childPosition == 1) { // phone
      imageView.setDrawableIcon(
          _context.getResources().getDrawable(R.drawable.ic_settings_phone_white));
    } else if (childPosition == 2) { // speed dial no
      imageView.setDrawableIcon(_context.getResources().getDrawable(R.drawable.phone_office));
    } else if (childPosition == 3) { // email
      imageView.setDrawableIcon(_context.getResources().getDrawable(R.drawable.mail_inv));
    } else if (childPosition == 4) { // dept
      imageView.setDrawableIcon(_context.getResources().getDrawable(R.drawable.department));
    }
    txtListChild.setText(childText);

    convertView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            switch (childPosition) {
              case 0:
                break;
              case 1:
                Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + childText));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                _context.startActivity(intent);
                break;
              case 2:
                break;
              case 3:
                Intent emailIntent = new Intent(Intent.ACTION_SEND);
                emailIntent.setType("message/rfc822");
                emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {childText});
                try {
                  _context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
                } catch (android.content.ActivityNotFoundException ex) {
                  Toast.makeText(
                          _context, "There is no email client installed.", Toast.LENGTH_SHORT)
                      .show();
                }
                break;
            }
          }
        });

    return convertView;
  }
예제 #2
0
 /** Method that shows the buttons and text message when there's no diet registered */
 private void showButtons() {
   ButtonFloat addbutton = (ButtonFloat) findViewById(R.id.button_add_diet);
   addbutton.setVisibility(View.VISIBLE);
   TextView noDietMessage = (TextView) findViewById(R.id.no_diet_message);
   noDietMessage.setVisibility(View.VISIBLE);
 }