Example usage for android.widget TableRow setBackgroundColor

List of usage examples for android.widget TableRow setBackgroundColor

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:com.google.adsensequickstart.DisplayInventoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ScrollView sv = new ScrollView(getActivity());
    TableLayout tl = new TableLayout(getActivity());
    tl.setBackgroundColor(Color.rgb(242, 239, 233));
    sv.addView(tl);// w  w w.  j  av a 2 s  .co  m

    if (displayInventoryController == null) {
        return sv;
    }
    Inventory inventory = displayInventoryController.getInventory();

    TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    tableRowParams.setMargins(1, 1, 1, 1);

    TableRow.LayoutParams accountLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    accountLayoutParams.setMargins(2, 1, 2, 1);

    TableRow.LayoutParams adCLientLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    adCLientLayoutParams.setMargins(12, 1, 2, 1);

    TableRow.LayoutParams adUnitChannelLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    adUnitChannelLayoutParams.setMargins(24, 1, 2, 1);

    for (String accountId : inventory.getAccounts()) {
        TableRow trow = new TableRow(getActivity());
        tl.addView(trow);
        TextView tv = new TextView(getActivity());
        tv.setText(accountId);
        trow.addView(tv);
        tv.setLayoutParams(accountLayoutParams);

        for (String adClient : inventory.getAdClients(accountId)) {
            TableRow trow2 = new TableRow(getActivity());
            trow2.setBackgroundColor(Color.rgb(214, 204, 181));
            tl.addView(trow2);
            TextView tv2 = new TextView(getActivity());
            tv2.setText(adClient);
            trow2.addView(tv2);
            tv2.setLayoutParams(adCLientLayoutParams);
            for (String adUnit : inventory.getAdUnits(adClient)) {
                TableRow trow3 = new TableRow(getActivity());
                trow3.setBackgroundColor(Color.rgb(251, 145, 57));
                tl.addView(trow3);
                TextView tv3 = new TextView(getActivity());
                tv3.setText(adUnit);
                trow3.addView(tv3);
                tv3.setLayoutParams(adUnitChannelLayoutParams);
            }
            for (String customChannel : inventory.getCustomChannels(adClient)) {
                TableRow trow3 = new TableRow(getActivity());
                trow3.setBackgroundColor(Color.rgb(255, 195, 69));
                tl.addView(trow3);
                TextView tv3 = new TextView(getActivity());
                tv3.setText(customChannel);
                trow3.addView(tv3);
                tv3.setLayoutParams(adUnitChannelLayoutParams);
            }
        }
    }
    return sv;
}

From source file:org.smap.smapTask.android.activities.TaskAddressActivity.java

/** Called when the activity is first created. */
@Override/*from  w  w  w  .j a  va  2s .  com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.task_address);

    // Get the id of the selected list item
    Bundle bundle = getIntent().getExtras();

    taskEntry = Utilities.getTaskWithId(bundle.getLong("id"));

    try {

        //String assignment_status = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS));
        //String taskTitle = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_TITLE));
        //String taskAddress = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_ADDRESS));

        // Formatting
        LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        textLayout.setMargins(1, 1, 1, 1);

        TableRow.LayoutParams trLayout = new TableRow.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        trLayout.setMargins(1, 1, 1, 1);

        TableLayout tableLayout = (TableLayout) findViewById(R.id.task_address_values);

        // Add Title
        TextView title = (TextView) findViewById(R.id.task_title);
        title.setText(taskEntry.name);

        // Add Status
        TableRow r = new TableRow(this);
        r.setLayoutParams(trLayout);
        r.setBackgroundColor(0xff0000);
        TextView text1 = new TextView(this);
        text1.setText("Status");
        text1.setBackgroundColor(0xff0000);
        TextView text2 = new TextView(this);
        text2.setText(taskEntry.taskStatus);
        text2.setBackgroundColor(0xff0000);
        r.addView(text1);
        r.addView(text2);
        tableLayout.addView(r);

        // Put the Address items in the table
        Type type = new TypeToken<ArrayList<Address>>() {
        }.getType();
        ArrayList<Address> aArray = new Gson().fromJson(taskEntry.taskAddress, type);
        if (aArray != null) {
            for (int i = 0; i < aArray.size(); i++) {

                r = new TableRow(this);
                r.setLayoutParams(trLayout);
                r.setBackgroundColor(0xff0000);

                text1 = new TextView(this);
                text1.setText(aArray.get(i).name);
                text1.setBackgroundColor(0xff0000);

                text2 = new TextView(this);
                text2.setText(aArray.get(i).value);
                text2.setBackgroundColor(0xff0000);

                r.addView(text1);
                r.addView(text2);
                tableLayout.addView(r);
            }
        }

        // Create the buttons
        LinearLayout buttons = (LinearLayout) findViewById(R.id.task_address_buttons);
        //menu.setHeaderTitle(taskTitle);
        if (Utilities.canReject(taskEntry.taskStatus)) {

            Button b = new Button(this);
            b.setText("Reject Task");
            b.setId(R.id.reject_button);
            b.setOnClickListener(this);
            buttons.addView(b);
        }
        if (Utilities.canComplete(taskEntry.taskStatus)) {
            Button b = new Button(this);
            b.setText("Complete Task");
            b.setId(R.id.complete_button);
            b.setOnClickListener(this);
            buttons.addView(b);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.steveleach.scoresheet.ui.PlayersFragment.java

private void addHeaders() {
    TableRow headers = new TableRow(getActivity());
    addHeader(getString(R.string.playersNumHeader), headers, widths[0]);
    addHeader(getString(R.string.playersNameHeader), headers, widths[1]);
    addHeader(getString(R.string.playersActiveHeader), headers, widths[2]);
    headers.setBackgroundColor(getResources().getColor(R.color.applight));
    headers.setPadding(2, 2, 2, 2);//  ww w .  ja v a2 s  . c  o m
    playersTable.addView(headers);
}

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

private void selectRow(int index) {
    if (index != selectedIndex) {
        if (selectedIndex >= 0) {
            deselectRow(selectedIndex);/*from   w w w  .j a  v a 2 s  .c o  m*/
        }
        TableRow tr = (TableRow) tl.findViewWithTag(index);
        tr.setBackgroundColor(Color.LTGRAY);
        selectedIndex = index;
        TextView tv = (TextView) tr.getChildAt(0);
        selectedMake = tv.getText().toString();
        tv = (TextView) tr.getChildAt(1);
        selectedModel = tv.getText().toString();
        tv = (TextView) tr.getChildAt(2);
        selectedLicensePlate = tv.getText().toString();

        Vehicle v = getVehicle(selectedLicensePlate);
        sprof_make.setText(v.getMake());
        sprof_model.setText(v.getModel());
        sprof_color.setText(v.getColor());
        sprof_year.setText(v.getYear());
        sprof_licenseplate.setText(v.getLicensePlate());
    }
}

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

private void deselectRow(int index) {
    if (index >= 0) {
        TableRow tr = (TableRow) tl.findViewWithTag(index);
        if (tr != null) {
            tr.setBackgroundColor(Color.parseColor("#F2F7F2"));
        }/*from  ww  w.ja v a 2s.c  o  m*/
    }
}

From source file:com.mifos.utils.DataTableUIBuilder.java

public LinearLayout getDataTableLayout(final DataTable dataTable, JsonArray jsonElements,
        LinearLayout parentLayout, final Context context, final int entityId,
        DataTableActionListener mListener) {
    dataTableActionListener = mListener;

    /**/* w  ww.  j a v  a  2  s  . com*/
     * Create a Iterator with Json Elements to Iterate over the DataTable
     * Response.
     */
    Iterator<JsonElement> jsonElementIterator = jsonElements.iterator();
    /*
     * Each Row of the Data Table is Treated as a Table Here.
     * Creating the First Table for First Row
     */
    tableIndex = 0;
    while (jsonElementIterator.hasNext()) {
        TableLayout tableLayout = new TableLayout(context);
        tableLayout.setPadding(10, 10, 10, 10);

        final JsonElement jsonElement = jsonElementIterator.next();
        /*
        * Each Entry in a Data Table is Displayed in the
        * form of a table where each row contains one Key-Value Pair
        * i.e a Column Name - Column Value from the DataTable
        */
        int rowIndex = 0;
        while (rowIndex < dataTable.getColumnHeaderData().size()) {
            TableRow tableRow = new TableRow(context);
            tableRow.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
            tableRow.setPadding(10, 10, 10, 10);
            if (rowIndex % 2 == 0) {
                tableRow.setBackgroundColor(Color.LTGRAY);
            } else {
                tableRow.setBackgroundColor(Color.WHITE);
            }

            TextView key = new TextView(context);
            key.setText(dataTable.getColumnHeaderData().get(rowIndex).getColumnName());
            key.setGravity(Gravity.LEFT);
            TextView value = new TextView(context);
            value.setGravity(Gravity.RIGHT);
            if (jsonElement.getAsJsonObject().get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName())
                    .toString().contains("\"")) {
                value.setText(jsonElement.getAsJsonObject()
                        .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString()
                        .replace("\"", ""));
            } else {
                value.setText(jsonElement.getAsJsonObject()
                        .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString());
            }

            tableRow.addView(key, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tableRow.addView(value, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
            layoutParams.setMargins(12, 16, 12, 16);
            tableLayout.addView(tableRow, layoutParams);

            rowIndex++;
        }

        tableLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Toast.makeText(context, "Update Row " + tableIndex, Toast.LENGTH_SHORT).show();
            }
        });

        tableLayout.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {

                Toast.makeText(context, "Deleting Row " + tableIndex, Toast.LENGTH_SHORT).show();

                BaseApiManager baseApiManager = new BaseApiManager();
                DataManager dataManager = new DataManager(baseApiManager);
                Observable<GenericResponse> call = dataManager
                        .removeDataTableEntry(dataTable.getRegisteredTableName(), entityId,
                                Integer.parseInt(jsonElement.getAsJsonObject()
                                        .get(dataTable.getColumnHeaderData().get(0).getColumnName())
                                        .toString()));
                Subscription subscription = call.subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<GenericResponse>() {
                            @Override
                            public void onCompleted() {

                            }

                            @Override
                            public void onError(Throwable e) {

                            }

                            @Override
                            public void onNext(GenericResponse genericResponse) {
                                Toast.makeText(context, "Deleted Row " + tableIndex, Toast.LENGTH_SHORT).show();
                                dataTableActionListener.onRowDeleted();
                            }
                        });

                return true;
            }
        });

        View v = new View(context);
        v.setBackgroundColor(ContextCompat.getColor(context, R.color.black));
        parentLayout.addView(tableLayout);
        parentLayout.addView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 5));
        Log.i("TABLE INDEX", "" + tableIndex);
        tableIndex++;
    }
    return parentLayout;
}

From source file:com.chalmers.schmaps.CheckBusActivity.java

/**
 * Makes the rows for the chalmerstable// ww w. ja  va  2 s .c om
 */
public void makeChalmersRows() {
    for (int i = 0; i < NROFROWS; i++) {
        TableRow tempTableRow = new TableRow(this);
        tempTableRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

        // Makes every other row light gray or white
        if (i % 2 == 0) {
            tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_grey));
        } else {
            tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_white));
        }

        //Makes every textview for each column and add it before starting with a new one
        for (int j = 0; j < NR_OF_COLUMNS; j++) {
            TextView textview = new TextView(this);
            textview.setTextColor(Color.BLACK);
            textview.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
            //Check which content should be written in the textview
            if (j == COLUMN_NR_1) {
                textview.setText(chalmersLineArray.get(i));
            } else if (j == COLUMN_NR_2) {
                textview.setText(chalmersDestArray.get(i));
            } else if (j == COLUMN_NR_3) {
                textview.setText(chalmersTimeArray.get(i));
            } else if (j == COLUMN_NR_4) {
                textview.setText(chalmersTrackArray.get(i));
            }
            textview.setGravity(Gravity.CENTER_HORIZONTAL);
            tempTableRow.addView(textview);
        }
        chalmersTable.addView(tempTableRow,
                new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    }
}

From source file:com.chalmers.schmaps.CheckBusActivity.java

/**
 * Makes the rows for the lindholmentable
 *//*ww w . j a  va 2s .c o m*/
public void makeLindholmenRows() {
    for (int i = 0; i < NROFROWS; i++) {
        TableRow tempTableRow = new TableRow(this);
        tempTableRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

        // Makes every other row light gray or white
        if (i % 2 == 0) {
            tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_grey));
        } else {
            tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_white));
        }

        //Makes every textview for each column and add it before starting with a new one 
        for (int j = 0; j < NR_OF_COLUMNS; j++) {
            TextView textview = new TextView(this);
            textview.setTextColor(Color.BLACK);
            textview.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
            //Check which content should be written in the textview
            if (j == COLUMN_NR_1) {
                textview.setText(lindholmenLineArray.get(i));
            } else if (j == COLUMN_NR_2) {
                textview.setText(lindholmenDestArray.get(i));
            } else if (j == COLUMN_NR_3) {
                textview.setText(lindholmenTimeArray.get(i));
            } else if (j == COLUMN_NR_4) {
                textview.setText(lindholmenTrackArray.get(i));
            }

            textview.setGravity(Gravity.CENTER_HORIZONTAL);
            tempTableRow.addView(textview);
        }
        lindholmenTable.addView(tempTableRow,
                new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    }
}

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

public void getCurrInfo() {
    tag = 1;/* ww  w  .j  ava 2  s.  c  om*/

    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:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    user = (User) getArguments().getSerializable(USER_KEY);
    vehicles = (Vehicle[]) getArguments().getSerializable(SEEKER_VEHICLES_KEY);

    getCurrInfo();//from ww w  .ja v a 2  s  .com

    rootView = inflater.inflate(R.layout.fragment_seeker_profile_vehicle, container, false);

    sprof_make = (EditText) rootView.findViewById(R.id.sprof_make);
    sprof_model = (EditText) rootView.findViewById(R.id.sprof_model);
    sprof_color = (EditText) rootView.findViewById(R.id.sprof_color);
    sprof_year = (EditText) rootView.findViewById(R.id.sprof_year);
    sprof_licenseplate = (EditText) rootView.findViewById(R.id.sprof_licenseplate);

    tl = (TableLayout) rootView.findViewById(R.id.sprof_vehicle_table);

    sprof_add_vehicle_button = (Button) rootView.findViewById(R.id.sprof_add_vehicle_button);
    sprof_edit_vehicle_button = (Button) rootView.findViewById(R.id.sprof_edit_vehicle_button);
    sprof_delete_vehicle_button = (Button) rootView.findViewById(R.id.sprof_delete_vehicle_button);

    sprof_add_vehicle_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            String make = sprof_make.getText().toString();
            String model = sprof_model.getText().toString();
            String color = sprof_color.getText().toString();
            String year = sprof_year.getText().toString();
            String licensePlate = sprof_licenseplate.getText().toString();

            Vehicle vehicle = new Vehicle();
            vehicle.setMake(make);
            vehicle.setModel(model);
            vehicle.setColor(color);
            vehicle.setYear(year);
            vehicle.setLicensePlate(licensePlate);

            if (!validate(vehicle)) {
                onAddUpdateVehicleFailed();
                return;
            }

            Vehicle v = getVehicle(licensePlate);
            if (v.getMake() == null) {
                addVehicle(vehicle);
            } else {
                Snackbar.make(rootView, "Vehicle with this license plate already exists; cannot re-add",
                        Snackbar.LENGTH_LONG).show();
            }
        }
    });

    sprof_edit_vehicle_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (selectedMake.equals("")) {
                Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show();
            } else {
                String make = sprof_make.getText().toString();
                String model = sprof_model.getText().toString();
                String color = sprof_color.getText().toString();
                String year = sprof_year.getText().toString();
                String licensePlate = sprof_licenseplate.getText().toString();

                Vehicle vehicle = new Vehicle();
                vehicle.setMake(make);
                vehicle.setModel(model);
                vehicle.setColor(color);
                vehicle.setYear(year);
                vehicle.setLicensePlate(licensePlate);

                if (!validate(vehicle)) {
                    onAddUpdateVehicleFailed();
                    return;
                } else if (!licensePlate.equals(selectedLicensePlate)) {
                    Snackbar.make(rootView,
                            "Cannot update vehicle license plate; add a new vehicle with this license plate",
                            Snackbar.LENGTH_LONG).show();
                } else {
                    vehicles[selectedIndex - 1] = vehicle;
                    TableRow tr = (TableRow) tl.findViewWithTag(selectedIndex);
                    tr.setBackgroundColor(Color.LTGRAY);
                    TextView tv = (TextView) tr.getChildAt(0);
                    tv.setText(vehicle.getMake());
                    tv = (TextView) tr.getChildAt(1);
                    tv.setText(vehicle.getModel());
                    editVehicle();
                }
            }
        }
    });

    sprof_delete_vehicle_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (selectedMake.equals("")) {
                Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show();
            } else if (tag == 2) {
                Snackbar.make(rootView, "Must add another vehicle before deleting your only listed vehicle",
                        Snackbar.LENGTH_LONG).show();
            } else {
                LayoutInflater li = LayoutInflater.from(myContext);
                View customView = li.inflate(R.layout.popup_delete_vehicle, null);

                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(myContext);
                alertDialogBuilder.setView(customView);
                final AlertDialog alertDialog = alertDialogBuilder.create();

                TextView deleteText = (TextView) customView.findViewById(R.id.popup_delete_vehicle_text);
                deleteText.setText("Are you sure you want to delete this vehicle: " + selectedMake + " "
                        + selectedModel + " " + selectedLicensePlate + "?");

                ImageButton closeButton = (ImageButton) customView
                        .findViewById(R.id.popup_delete_vehicle_close);
                closeButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        alertDialog.dismiss();
                    }
                });

                Button deleteButton = (Button) customView.findViewById(R.id.popup_delete_vehicle_button);
                deleteButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        deleteVehicle();
                        alertDialog.dismiss();
                    }
                });

                alertDialog.show();
            }
        }
    });

    return rootView;
}