Example usage for android.widget TableRow setClickable

List of usage examples for android.widget TableRow setClickable

Introduction

In this page you can find the example usage for android.widget TableRow setClickable.

Prototype

public void setClickable(boolean clickable) 

Source Link

Document

Enables or disables click events for this view.

Usage

From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java

public void addVehicle(final Vehicle vehicle) {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create()).build();

    RequestInterface requestInterface = retrofit.create(RequestInterface.class);

    ServerRequest request = new ServerRequest();
    request.setOperation(Constants.ADD_VEHICLE_OPERATION);
    request.setUser(user);/*  w  w  w  .  j ava  2s. co  m*/
    request.setVehicle(vehicle);
    Call<ServerResponse> response = requestInterface.operation(request);

    response.enqueue(new Callback<ServerResponse>() {
        @Override
        public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) {
            ServerResponse resp = response.body();

            if (resp.getResult().equals(Constants.SUCCESS)) {
                TableRow tr = new TableRow(myContext);
                tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                        TableRow.LayoutParams.WRAP_CONTENT));
                tr.setTag(tag);
                tag++;
                tr.setClickable(true);
                tr.setOnClickListener(clickListener);

                TextView v_make = new TextView(myContext);
                v_make.setText(vehicle.getMake());
                v_make.setLayoutParams(new TableRow.LayoutParams(300, 150));
                tr.addView(v_make);

                TextView v_model = new TextView(myContext);
                v_model.setText(vehicle.getModel());
                v_model.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                        TableRow.LayoutParams.WRAP_CONTENT));
                tr.addView(v_model);

                TextView v_license = new TextView(myContext);
                v_license.setText(vehicle.getLicensePlate());
                v_license.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                        TableRow.LayoutParams.WRAP_CONTENT));
                tr.addView(v_license);

                tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,
                        TableLayout.LayoutParams.WRAP_CONTENT));

                Vehicle[] arr = new Vehicle[vehicles.length + 1];
                for (int i = 0; i < vehicles.length; i++) {
                    arr[i] = vehicles[i];
                }
                arr[vehicles.length] = vehicle;
                vehicles = arr;
            }
            Snackbar.make(rootView, resp.getMessage(), Snackbar.LENGTH_LONG).show();
        }

        @Override
        public void onFailure(Call<ServerResponse> call, Throwable t) {
            Snackbar.make(rootView, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show();
        }
    });
}

From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java

public void getCurrInfo() {
    tag = 1;//from w ww . ja v  a 2 s .  com

    Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create()).build();

    RequestInterface requestInterface = retrofit.create(RequestInterface.class);

    ServerRequest request = new ServerRequest();
    request.setOperation(Constants.GET_SEEKER_PROFILE_OPERATION);
    request.setUser(user);
    Call<ServerResponse> response = requestInterface.operation(request);

    response.enqueue(new Callback<ServerResponse>() {
        @Override
        public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) {
            ServerResponse resp = response.body();

            if (resp.getResult().equals(Constants.SUCCESS)) {
                vehicles = resp.getVehicles();

                TableRow tr_head = new TableRow(myContext);
                tr_head.setBackgroundColor(Color.GRAY);
                tr_head.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                        TableRow.LayoutParams.WRAP_CONTENT));

                TextView make = new TextView(myContext);
                make.setText("MAKE");
                make.setTextColor(Color.WHITE);
                make.setPadding(5, 5, 5, 5);
                tr_head.addView(make);

                TextView model = new TextView(myContext);
                model.setText("MODEL");
                model.setTextColor(Color.WHITE);
                model.setPadding(5, 5, 5, 5);
                tr_head.addView(model);

                final TextView license = new TextView(myContext);
                license.setText("LICENSE PLATE");
                license.setTextColor(Color.WHITE);
                license.setPadding(5, 5, 5, 5);
                tr_head.addView(license);

                tl.addView(tr_head, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,
                        TableLayout.LayoutParams.WRAP_CONTENT));

                for (int i = 0; i < vehicles.length; i++) {
                    if (vehicles[i].getDeletedWithHistory() == 1) {
                        continue;
                    }

                    TableRow tr = new TableRow(myContext);
                    tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                            TableRow.LayoutParams.WRAP_CONTENT));
                    tr.setTag(tag);
                    tag++;
                    tr.setClickable(true);
                    tr.setOnClickListener(clickListener);

                    TextView v_make = new TextView(myContext);
                    v_make.setText(vehicles[i].getMake());
                    v_make.setLayoutParams(new TableRow.LayoutParams(300, 150));
                    tr.addView(v_make);

                    TextView v_model = new TextView(myContext);
                    v_model.setText(vehicles[i].getModel());
                    v_model.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                            TableRow.LayoutParams.WRAP_CONTENT));
                    tr.addView(v_model);

                    TextView v_license = new TextView(myContext);
                    v_license.setText(vehicles[i].getLicensePlate());
                    v_license.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                            TableRow.LayoutParams.WRAP_CONTENT));
                    tr.addView(v_license);

                    tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,
                            TableLayout.LayoutParams.WRAP_CONTENT));
                }
            }
        }

        @Override
        public void onFailure(Call<ServerResponse> call, Throwable t) {
            Snackbar.make(rootView, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show();
        }
    });
}

From source file:se.frikod.payday.DailyBudgetFragment.java

private void updateBudgetItems() {

    TableLayout itemsTable = (TableLayout) V.findViewById(R.id.budgetItems);
    itemsTable.removeAllViews();/*from w w w  .  j  av  a  2 s  .co  m*/

    for (int i = 0; i < budget.budgetItems.size(); i++) {
        BudgetItem bi = budget.budgetItems.get(i);
        final int currentIndex = i;
        LayoutInflater inflater = activity.getLayoutInflater();
        TableRow budgetItemView = (TableRow) inflater.inflate(R.layout.daily_budget_budget_item, itemsTable,
                false);

        TextView amount = (TextView) budgetItemView.findViewById(R.id.budgetItemAmount);
        TextView title = (TextView) budgetItemView.findViewById(R.id.budgetItemLabel);

        amount.setText(budget.formatter.format(bi.amount));

        title.setText(bi.title);

        if (bi.exclude) {
            amount.setTextColor(0xffCCCCCC);
            amount.setPaintFlags(amount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

            title.setTextColor(0xffCCCCCC);
            title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        }

        budgetItemView.setClickable(true);
        budgetItemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
                vibrator.vibrate(10);

                BudgetItem bi = budget.budgetItems.get(currentIndex);
                bi.exclude = !bi.exclude;
                budget.saveBudgetItems();
                updateBudgetItems();
            }
        });

        budgetItemView.setLongClickable(true);
        budgetItemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                editBudgetItem(v, currentIndex);
                return true;
            }
        });
        itemsTable.addView(budgetItemView);
    }

    FontUtils.setRobotoFont(activity, itemsTable);
    updateBudget();
}

From source file:com.landenlabs.all_devtool.TextFragment.java

private void fillLayout() {
    m_tableLayout.removeAllViews();/*  ww w .  j a v a 2  s  . c  o  m*/
    m_textInfoList.clear();

    int minSP = 8;
    int maxSP = 20;
    int stepSP = 2;

    int[] colors = new int[] { 0xffe0e0e0, 0xffffe0e0, 0xffe0ffe0, 0xffe0e0ff };

    TableLayout.LayoutParams tableLP = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
            TableLayout.LayoutParams.WRAP_CONTENT);
    TableRow.LayoutParams rowLP = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
            TableRow.LayoutParams.MATCH_PARENT);

    TextView textView;
    TableRow tableRow;
    int textColor = 0xff000000;

    for (int tfIdx = 0; tfIdx < TextInfo.getCount(); tfIdx++) {
        Typeface typeface = TextInfo.getTypeface(tfIdx);
        String typefaceStr = TextInfo.getTypefaceStr(tfIdx);

        textView = new TextView(m_context);
        textView.setBackgroundColor(Utils.blend(colors[tfIdx], 0x20000000));
        textView.setText(typefaceStr);
        textView.setGravity(Gravity.CENTER);
        textView.setTextColor(textColor);
        m_tableLayout.addView(textView, tableLP);

        for (int sizeSP = minSP; sizeSP <= maxSP; sizeSP += stepSP) {
            tableRow = new TableRow(m_context);
            tableRow.setBackgroundColor(colors[tfIdx]);

            tableRow.setTag(Integer.valueOf(m_textInfoList.size()));
            m_textInfoList.add(new TextInfo(sizeSP, tfIdx));

            tableRow.setClickable(true);
            tableRow.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    int idx = (Integer) v.getTag();
                    showTextDialog(m_textInfoList, idx);
                }
            });

            textView = new TextView(m_context);
            textView.setText(String.valueOf(sizeSP) + "sp ");
            textView.setBackgroundColor(0x20000000);
            textView.setPadding(8, 0, 8, 0);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            textView = new TextView(m_context);
            textView.setText("Normal");
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP);
            textView.setTypeface(typeface, Typeface.NORMAL);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            textView = new TextView(m_context);
            textView.setText("Bold");
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP);
            textView.setTypeface(typeface, Typeface.BOLD);
            textView.setPadding(8, 0, 8, 0);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            textView = new TextView(m_context);
            textView.setText("Italic");
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP);
            textView.setTypeface(typeface, Typeface.ITALIC);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            m_tableLayout.addView(tableRow, tableLP);
        }
    }
}