Example usage for android.widget TableLayout getWidth

List of usage examples for android.widget TableLayout getWidth

Introduction

In this page you can find the example usage for android.widget TableLayout getWidth.

Prototype

@ViewDebug.ExportedProperty(category = "layout")
public final int getWidth() 

Source Link

Document

Return the width of your view.

Usage

From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java

@Override
protected void onServiceBound() {
    L.d("ServiceActionMenuActivity onServiceBound()");
    final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf");
    final int defaultFirstRowTextColor = Color.parseColor("#646464");

    final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class);
    final ServiceMenu menu = friendsPlugin.getStore().getMenu(email, page);

    TableLayout menu_table = (TableLayout) findViewById(R.id.menu_table);
    int tableWidth = menu_table.getWidth();
    for (int x = 0; x < 4; x++) {
        for (int y = 0; y < 3; y++) {
            android.view.ViewGroup cellLayout = (android.view.ViewGroup) findViewById(
                    getResources().getIdentifier("menu_" + x + "x" + y, "id", getPackageName()));
            android.view.ViewGroup.LayoutParams lp = cellLayout.getLayoutParams();
            lp.width = tableWidth / 4;// w ww  .  jav a  2  s. c  o m
            cellLayout.setLayoutParams(lp);
            Cell cell = new Cell();
            cell.icon = (ImageView) cellLayout.findViewById(R.id.icon);
            cell.faIcon = (TextView) cellLayout.findViewById(R.id.fa_icon);
            cell.label = (TextView) cellLayout.findViewById(R.id.label);
            cells[x][y] = cell;
            if (y == 0) {
                cell.icon.setVisibility(View.GONE);
                cell.faIcon.setTypeface(faTypeFace);
                cell.faIcon.setTextColor(defaultFirstRowTextColor);
                switch (x) {
                case 0:
                    cell.faIcon.setVisibility(View.VISIBLE);
                    cell.faIcon.setText(R.string.fa_info);
                    break;
                case 1:
                    cell.faIcon.setVisibility(View.VISIBLE);
                    cell.faIcon.setText(R.string.fa_envelope);
                    break;
                case 2:
                    cell.faIcon.setVisibility(View.INVISIBLE);
                    cell.faIcon.setText(R.string.fa_phone);
                    break;
                case 3:
                    cell.faIcon.setVisibility(View.INVISIBLE);
                    cell.faIcon
                            .setText(CloudConstants.isYSAAA() ? R.string.fa_qrcode : R.string.fa_thumbs_o_up);
                    break;

                default:
                    break;
                }
            }
        }
    }
    for (int y = 0; y < 3; y++) {
        TableRow row = (TableRow) findViewById(getResources().getIdentifier("row" + y, "id", getPackageName()));
        tableRows[y] = row;
    }
    clearScreen();

    populateScreen(menu);
    IntentFilter filter = new IntentFilter(FriendsPlugin.FRIEND_UPDATE_INTENT);
    filter.addAction(FriendsPlugin.FRIEND_REMOVED_INTENT);
    filter.addAction(FriendsPlugin.FRIEND_MARKED_FOR_REMOVAL_INTENT);
    filter.addAction(MessagingPlugin.NEW_MESSAGE_RECEIVED_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_PROCESSED_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_LOCKED_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_DIRTY_CLEANED_INTENT);
    filter.addAction(MessagingPlugin.THREAD_DELETED_INTENT);
    filter.addAction(MessagingPlugin.THREAD_RECOVERED_INTENT);
    filter.addAction(BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT);
    filter.addAction(BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_JSMFR_ERROR);
    registerReceiver(mBroadcastReceiver, filter);

    findViewById(R.id.navigation_bar_home_button).setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            Intent i = new Intent(ServiceActionMenuActivity.this, HomeActivity.class);
            i.setFlags(MainActivity.FLAG_CLEAR_STACK);
            startActivity(i);
            finish();
        }
    });
}