Java Code Examples for android.widget.TableLayout#addView()

The following examples show how to use android.widget.TableLayout#addView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableEntry.java    From Markwon with Apache License 2.0 6 votes vote down vote up
@NonNull
private TableRow ensureRow(@NonNull TableLayout layout, int row) {

    final int count = layout.getChildCount();

    // fill the requested views until we have added the `row` one
    if (row >= count) {

        final Context context = layout.getContext();

        int diff = row - count + 1;
        while (diff > 0) {
            layout.addView(new TableRow(context));
            diff -= 1;
        }
    }

    // return requested child (here it always should be the last one)
    return (TableRow) layout.getChildAt(row);
}
 
Example 2
Source File: RecipeActivity.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity)getActivity()).recipe;

    TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null);
        ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example 3
Source File: DeviceInfoActivity.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
private void addRow(TableLayout parent, String key, String value) {
    TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);

    TextView textViewKey = new TextView(this);
    textViewKey.setText(key);
    textViewKey.setLayoutParams(rowParams);

    TextView textViewValue = new TextView(this);
    textViewValue.setText(value);
    textViewValue.setLayoutParams(rowParams);

    TableRow tableRow = new TableRow(this);
    tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
    tableRow.addView(textViewKey);
    tableRow.addView(textViewValue);

    parent.addView(tableRow);
}
 
Example 4
Source File: RecipeActivity.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity)getActivity()).recipe;

    TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null);
        ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example 5
Source File: RecipeActivity.java    From search-samples with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity)getActivity()).recipe;

    TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null);
        ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example 6
Source File: QuestionFragment.java    From android-galaxyzoo with GNU General Public License v3.0 6 votes vote down vote up
private static TableRow addRowToTable(final Activity activity, final TableLayout layoutAnswers) {
    final TableRow row = new TableRow(activity);

    final TableLayout.LayoutParams params =
            new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                    TableLayout.LayoutParams.MATCH_PARENT);

    //Add a top margin between this row and any row above it:
    if (layoutAnswers.getChildCount() > 0) {
        final int margin = UiUtils.getPxForDpResource(activity, R.dimen.tiny_gap);
        params.setMargins(0, margin, 0, 0);
    }

    layoutAnswers.addView(row, params);
    return row;
}
 
Example 7
Source File: PageHandler.java    From SI with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void appendRow( String value ){

        // create table row
        TableLayout tb = (TableLayout)findViewById(R.id.control_table_layout);
        TableRow tableRow = new TableRow(this);
        tableRow.setLayoutParams(tableLayout);

        // get current time
        long time = System.currentTimeMillis();
        SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String cur_time = dayTime.format(new Date(time));

        // set Text on TextView
        TextView tv_left = new TextView(this);
        tv_left.setText( cur_time );
        tv_left.setLayoutParams( tableRowLayout );
        tableRow.addView( tv_left );

        TextView tv_right = new TextView(this);
        tv_right.setText( value );
        tv_right.setLayoutParams( tableRowLayout );
        tableRow.addView( tv_right );

        // set table rows on table
        tb.addView(tableRow);
    }
 
Example 8
Source File: RecipeActivity.java    From app-indexing with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity) getActivity()).mRecipe;

    TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
        ((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
                .getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example 9
Source File: RecipeActivity.java    From app-indexing with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity) getActivity()).mRecipe;

    TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
        ((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
                .getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example 10
Source File: DebugActivity.java    From sony-smartband-open-api with MIT License 5 votes vote down vote up
private void uiPopulateRows( TableLayout tl ) {
    tl.addView( createRow( RowId.STATUS          , "Status:"          , "-", "Connect", mClickListener ) );
    tl.addView( createRow( RowId.UPTIME          , "Uptime:"          , "-", "Update" , mClickListener ) );
    tl.addView( createRow( RowId.CURRENT_MODE    , "Current Mode:"    , "-", "Update" , mClickListener ) );
    tl.addView( createRow( RowId.PROTOCOL_VERSION, "Protocol Version:", "-", "Update" , mClickListener ) );
    tl.addView( createRow( RowId.CURRENT_TIME    , "Current Time:"    , "-", "Update" , mClickListener ) );

    tl.addView( createRow( RowId.BATTERY_LEVEL, "Battery Level:", "-", "Update" , mClickListener ) );

    tl.addView( createRow( RowId.FIRMWARE_REVISION, "Firmware Rev.:", "-", "Update", mClickListener ) );
    tl.addView( createRow( RowId.HARDWARE_REVISION, "Hardware Rev.:", "-", "Update", mClickListener ) );
    tl.addView( createRow( RowId.SOFTWARE_REVISION, "Software Rev.:", "-", "Update", mClickListener ) );
    tl.addView( createRow( RowId.MANUFACTURER_NAME, "Manufacturer:" , "-", "Update", mClickListener ) );

    tl.addView( createRow( RowId.AAS_VERSION   , "AAS Version:"  , "-", "Update", mClickListener ) );
    tl.addView( createRow( RowId.AAS_SMART_LINK, "AAS SmartLink:", "-", "Update", mClickListener ) );
    tl.addView( createRow( RowId.AAS_PRODUCT_ID, "AAS ProductId:", "-", "Update", mClickListener ) );
    tl.addView( createRow( RowId.AAS_DATA      , "AAS Data:"     , "-", "Update", mClickListener ) );

    tl.addView( createRow( RowId.GA_DEVICE_NAME, "GA Device Name:", "-", "Update", mClickListener ) );

    tl.addView( createRow( RowId.SEND_CURRENT_TIME, "Send Current Time:", "-", "Update", mClickListener ) );

    tl.addView( createRow( RowId.ENABLE_EVENT_NOTIFICATIONS, "Event Notifications:" , "-", "Enable", mClickListener ) );
    tl.addView( createRow( RowId.ENABLE_DATA_NOTIFICATIONS , "Data Notifications:"  , "-", "Enable", mClickListener ) );
    tl.addView( createRow( RowId.ENABLE_ACC_NOTIFICATIONS  , "Accelerometer Notif.:", "-", "Enable", mClickListener ) );
    tl.addView( createRow( RowId.ENABLE_DEBUG_NOTIFICATIONS, "Debug Notifications:" , "-", "Enable", mClickListener ) );
}
 
Example 11
Source File: AdoptDialogBuilder.java    From Hauk with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a View that is rendered in the dialog window.
 *
 * @param ctx Android application context.
 * @return A View instance to render on the dialog.
 */
@Override
public final View createView(Context ctx) {
    // TODO: Inflate this instead
    // Ensure input boxes fill the entire width of the dialog.
    TableRow.LayoutParams trParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT);
    trParams.weight = 1.0F;

    TableLayout layout = new TableLayout(ctx);
    TableRow shareRow = new TableRow(ctx);
    shareRow.setLayoutParams(trParams);
    TableRow nickRow = new TableRow(ctx);
    nickRow.setLayoutParams(trParams);

    TextView textShare = new TextView(ctx);
    textShare.setText(R.string.label_share_url);

    TextView textNick = new TextView(ctx);
    textNick.setText(R.string.label_nickname);

    this.dialogTxtShare = new EditText(ctx);
    this.dialogTxtShare.setInputType(InputType.TYPE_CLASS_TEXT);
    this.dialogTxtShare.setLayoutParams(trParams);
    this.dialogTxtShare.addTextChangedListener(new LinkIDMatchReplacementListener(this.dialogTxtShare));

    this.dialogTxtNick = new EditText(ctx);
    this.dialogTxtNick.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    this.dialogTxtNick.setLayoutParams(trParams);

    shareRow.addView(textShare);
    shareRow.addView(this.dialogTxtShare);
    nickRow.addView(textNick);
    nickRow.addView(this.dialogTxtNick);

    layout.addView(shareRow);
    layout.addView(nickRow);

    return layout;
}
 
Example 12
Source File: ScoresActivity.java    From tedroid with Apache License 2.0 5 votes vote down vote up
/**
 * Setea los valores de los objetos Score proporcionados o manda un mensaje si no hay datos.
 * 
 * @param scores objetos Score.
 */
private void setUpScores(List<Score> scores, TableLayout table) {
    if (scores != null && !scores.isEmpty()) {
        table.removeAllViews();
        table.addView(createHeaderRow());
        for (Score score : scores) table.addView(toTableRow(score));
    } else {
        table.removeAllViews();
        table.addView(emptyScoresRow());
    }
}
 
Example 13
Source File: DisplayModelActivity.java    From nosey with Apache License 2.0 5 votes vote down vote up
public void addModelFieldHeaders(TableLayout table, Inspector.ModelMapInspector inspector) {
    // Get Fields for a given model
    model.getDeclaredFields();
    Field[] allFields = model.getDeclaredFields();
    Arrays.sort(allFields, new MemberComparator<Field>());

    // Add the field headers to the table row
    TableRow headers = new ColoredTableRow(this, RowColors.getColor(table.getChildCount()));
    for (Field field : allFields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            headers.addView(new CellTextView(this, field.getName(), padding, textSize));
        }
    }
    table.addView(headers);
}
 
Example 14
Source File: DisplayModelActivity.java    From nosey with Apache License 2.0 5 votes vote down vote up
public void addModelFieldHeaders(TableLayout table, Inspector.ModelMapInspector inspector) {
    // Get Fields for a given model
    model.getDeclaredFields();
    Field[] allFields = model.getDeclaredFields();
    Arrays.sort(allFields, new MemberComparator<Field>());

    // Add the field headers to the table row
    TableRow headers = new ColoredTableRow(this, RowColors.getColor(table.getChildCount()));
    for (Field field : allFields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            headers.addView(new CellTextView(this, field.getName(), padding, textSize));
        }
    }
    table.addView(headers);
}
 
Example 15
Source File: BodyElementTable.java    From RedReader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View generateView(
		@NonNull final AppCompatActivity activity,
		@Nullable final Integer textColor,
		@Nullable final Float textSize,
		final boolean showLinkButtons) {

	final TableLayout table = new TableLayout(activity);

	for(final BodyElement element : mElements) {

		final View view = element.generateView(activity, textColor, textSize, showLinkButtons);
		table.addView(view);
	}

	table.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
	table.setDividerDrawable(new ColorDrawable(Color.GRAY));

	table.setLayoutParams(new ViewGroup.LayoutParams(
			ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT));

	final HorizontalScrollView scrollView = new HorizontalScrollView(activity);

	scrollView.addView(table);

	return scrollView;
}
 
Example 16
Source File: MainActivity.java    From video-tutorial-code with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void populateButtons() {
   	TableLayout table = (TableLayout) findViewById(R.id.tableForButtons);
   	
   	for (int row = 0; row < NUM_ROWS; row++) {
   		TableRow tableRow = new TableRow(this);
   		tableRow.setLayoutParams(new TableLayout.LayoutParams(
   				TableLayout.LayoutParams.MATCH_PARENT,
   				TableLayout.LayoutParams.MATCH_PARENT,
   				1.0f));
   		table.addView(tableRow);
   		
   		for (int col = 0; col < NUM_COLS; col++){ 
   			final int FINAL_COL = col;
   			final int FINAL_ROW = row;
   			
   			Button button = new Button(this);
   			button.setLayoutParams(new TableRow.LayoutParams(
   					TableRow.LayoutParams.MATCH_PARENT,
   					TableRow.LayoutParams.MATCH_PARENT,
   					1.0f));
   			
   			button.setText("" + col + "," + row);
   			
   			// Make text not clip on small buttons
   			button.setPadding(0, 0, 0, 0);
   			
   			button.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					gridButtonClicked(FINAL_COL, FINAL_ROW);
				}
			});
   			
   			tableRow.addView(button);
   			buttons[row][col] = button;
   		}
   	}
}
 
Example 17
Source File: IPSettingActivity.java    From faceswap with Apache License 2.0 4 votes vote down vote up
private void addPersonUIRow(final SharedPreferences mSharedPreferences, final int type,
                            final String name, String ip) {
    final TableLayout tb=tbs[type];

    //create a new table row
    final TableRow tr = new TableRow(this);
    TableRow.LayoutParams trTlp = new TableRow.LayoutParams(
            0,
            TableLayout.LayoutParams.WRAP_CONTENT
    );
    tr.setLayoutParams(trTlp);

    //create name view
    TextView nameView = new TextView(this);
    nameView.setText(name);
    nameView.setTextSize(20);
    TableRow.LayoutParams tlp1 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp1.column=0;
    nameView.setLayoutParams(tlp1);

    //create sub view
    TextView subView = new TextView(this);
    subView.setText(ip);
    subView.setTextSize(20);
    TableRow.LayoutParams tlp3 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp3.column=1;
    subView.setLayoutParams(tlp3);

    //create delete button
    ImageView deleteView = new ImageView(this);
    deleteView.setImageResource(R.drawable.ic_delete_black_24dp);
    TableRow.LayoutParams tlp4 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp4.column=2;
    deleteView.setLayoutParams(tlp4);
    deleteView.setOnClickListener(new ImageView.OnClickListener() {
        @Override
        public void onClick(View v) {
            //remove name from sharedPreferences
            String sharedPreferenceIpDictName=
                    getResources().getStringArray(R.array.shared_preference_ip_dict_names)[type];
            SharedPreferences.Editor editor = mSharedPreferences.edit();
            Set<String> existingNames =
                    new HashSet<String>(mSharedPreferences.getStringSet(sharedPreferenceIpDictName,
                            new HashSet<String>()));
            editor.remove(name);
            existingNames.remove(name);
            editor.putStringSet(sharedPreferenceIpDictName, existingNames);
            editor.commit();

            //remove current line from UI
            tb.removeView(tr);
        }
    });

    tr.addView(nameView);
    tr.addView(subView);
    tr.addView(deleteView);

    tb.addView(tr,
            new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                    TableLayout.LayoutParams.WRAP_CONTENT));
}
 
Example 18
Source File: fwSelectorView.java    From SensorTag-CC2650 with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder fwDialog = new AlertDialog.Builder(getActivity())
            .setTitle("Select Factory FW")
            .setNegativeButton("Cancel", null);

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View fwView = inflater.inflate(R.layout.fw_selector, null);

    table = (TableLayout) fwView.findViewById(R.id.fwentries_layout);
    table.removeAllViews();
    /* Initialize view from file */
    if (this.firmwares != null) {
        for(int ii = 0; ii < this.firmwares.size(); ii++) {
            tiFirmwareEntry entry = this.firmwares.get(ii);
            if (entry.RequiredVersionRev > cFW) {
                entry.compatible = false;
            }
            if (entry.Version < cFW) {
                entry.compatible = false;
            }
            final firmwareEntryTableRow tRow = new firmwareEntryTableRow(getActivity(),entry);
            GradientDrawable g = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
                    new int[] { Color.WHITE, Color.LTGRAY});
            g.setGradientType(GradientDrawable.LINEAR_GRADIENT);
            StateListDrawable states = new StateListDrawable();
            states.addState(new int[] {android.R.attr.state_pressed,-android.R.attr.state_selected},g);

            tRow.setBackgroundDrawable(states);
            tRow.position = ii;
            tRow.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.d("fwSelectorView", "Firmware cell clicked");
                    final Intent intent = new Intent(ACTION_FW_WAS_SELECTED);
                    intent.putExtra(EXTRA_SELECTED_FW_INDEX,tRow.position);
                    getActivity().sendBroadcast(intent);
                    dismiss();
                }
            });
            if (entry.compatible == true)tRow.setGrayedOut(false);
            else tRow.setGrayedOut(true);
            table.addView(tRow);
            table.requestLayout();

        }

    }
    fwDialog.setView(fwView);
    Dialog fwSelectorDialog = fwDialog.create();
    return fwSelectorDialog;
}
 
Example 19
Source File: MonsterStatusFragment.java    From MonsterHunter4UDatabase with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_monster_status, container, false);

    mStatusTable = (TableLayout) view.findViewById(R.id.statusTable);

    ArrayList<MonsterStatus> statuses =
            DataManager.get(getActivity()).queryMonsterStatus(getArguments().getLong(ARG_MONSTER_ID));

    MonsterStatus currentStatus = null;
    String status, initial, increase, max, duration, damage;
    String imageFile;

    for(int i = 0; i < statuses.size(); i++) {
        TableRow wdRow = (TableRow) inflater.inflate(
                R.layout.fragment_monster_status_listitem, mStatusTable, false);

        currentStatus = statuses.get(i);

        // Get our strings and our views
        status = currentStatus.getStatus();
        initial = Long.toString(currentStatus.getInitial());
        increase = Long.toString(currentStatus.getIncrease());
        max = Long.toString(currentStatus.getMax());
        duration = Long.toString(currentStatus.getDuration());
        damage = Long.toString(currentStatus.getDamage());

        ImageView statusImage = (ImageView) wdRow.findViewById(R.id.statusImage);
        TextView initialView = (TextView) wdRow.findViewById(R.id.initial);
        TextView increaseView = (TextView) wdRow.findViewById(R.id.increase);
        TextView maxView = (TextView) wdRow.findViewById(R.id.max);
        TextView durationView = (TextView) wdRow.findViewById(R.id.duration);
        TextView damageView = (TextView) wdRow.findViewById(R.id.damage);

        // Check which image to load
        boolean image = true;
        imageFile = "icons_monster_info/";
        switch (status)
        {
            case "Poison":
                imageFile = imageFile + "Poison.png";
                break;
            case "Sleep":
                imageFile = imageFile + "Sleep.png";
                break;
            case "Para":
                imageFile = imageFile + "Paralysis.png";
                break;
            case "KO":
                imageFile = imageFile + "Stun.png";
                break;
            case "Exhaust":
                //statusView.setText(status);
                imageFile = imageFile + "exhaust.png";
                break;
            case "Blast":
                imageFile = imageFile + "Blastblight.png";
                break;
            case "Jump":
                //statusView.setText(status);
                imageFile = imageFile + "jump.png";
                break;
            case "Mount":
                //statusView.setText(status);
                imageFile = imageFile + "mount.png";
                break;
        }

        // initialize our views
        initialView.setText(initial);
        increaseView.setText(increase);
        maxView.setText(max);
        durationView.setText(duration);
        damageView.setText(damage);

        if (image) {
            Drawable draw = null;
            try {
                draw = Drawable.createFromStream(
                        getActivity().getAssets().open(imageFile), null);
            } catch (IOException e) {
                e.printStackTrace();
            }
            android.view.ViewGroup.LayoutParams layoutParams = statusImage.getLayoutParams();
            statusImage.setLayoutParams(layoutParams);

            statusImage.setImageDrawable(draw);
        }

        mStatusTable.addView(wdRow);
    }

    return view;
}
 
Example 20
Source File: ContactDetailsFragment.java    From Linphone4Android with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("InflateParams")
private void displayContact(LayoutInflater inflater, View view) {
	ImageView contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
	if (contact.hasPhoto()) {
		LinphoneUtils.setImagePictureFromUri(getActivity(), contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
       } else {
       	contactPicture.setImageResource(R.drawable.avatar);
       }
	
	TextView contactName = (TextView) view.findViewById(R.id.contact_name);
	contactName.setText(contact.getFullName());
	
	TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
	controls.removeAllViews();
	for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
		boolean skip = false;
		View v = inflater.inflate(R.layout.contact_control_row, null);

		String value = noa.getValue();
		String displayednumberOrAddress = LinphoneUtils.getDisplayableUsernameFromAddress(value);

		TextView label = (TextView) v.findViewById(R.id.address_label);
		if (noa.isSIPAddress()) {
			label.setText(R.string.sip_address);
			skip |= getResources().getBoolean(R.bool.hide_contact_sip_addresses);
		} else {
			label.setText(R.string.phone_number);
			skip |= getResources().getBoolean(R.bool.hide_contact_phone_numbers);
		}
		
		TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
		tv.setText(displayednumberOrAddress);
		tv.setSelected(true);
		

		LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
		if (lpc != null) {
			String username = lpc.normalizePhoneNumber(displayednumberOrAddress);
			value = LinphoneUtils.getFullAddressFromUsername(username);
		}

		String contactAddress = contact.getPresenceModelForUri(noa.getValue());
		if (contactAddress != null) {
			v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE);
		}
		
		if (!displayChatAddressOnly) {
			v.findViewById(R.id.contact_call).setOnClickListener(dialListener);
			if (contactAddress != null) {
				v.findViewById(R.id.contact_call).setTag(contactAddress);
			} else {
				v.findViewById(R.id.contact_call).setTag(value);
			}
		} else {
			v.findViewById(R.id.contact_call).setVisibility(View.GONE);
		}

		v.findViewById(R.id.contact_chat).setOnClickListener(chatListener);
		if (contactAddress != null) {
			v.findViewById(R.id.contact_chat).setTag(contactAddress);
		} else {
			v.findViewById(R.id.contact_chat).setTag(value);
		}
		
		if (getResources().getBoolean(R.bool.disable_chat)) {
			v.findViewById(R.id.contact_chat).setVisibility(View.GONE);
		}
		
		if (!skip) {
			controls.addView(v);
		}
	}
}