Example usage for android.view Gravity CENTER

List of usage examples for android.view Gravity CENTER

Introduction

In this page you can find the example usage for android.view Gravity CENTER.

Prototype

int CENTER

To view the source code for android.view Gravity CENTER.

Click Source Link

Document

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.

Usage

From source file:com.android.returncandidate.activities.SdmScannerActivity.java

/**
 * Show warning dialog when ? is clicked
 *//*from w  w  w . j  av a2 s  . com*/
private void showDialog() {

    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setMessage(getString(R.string.cancel_msg)).setCancelable(false)
            .setPositiveButton(getString(R.string.logout_yes), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cancelItem();
                    btnCancel.setEnabled(true);
                }
            }).setNegativeButton(getString(R.string.logout_no), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    btnCancel.setEnabled(true);
                }
            });
    AlertDialog alert = dialog.show();
    TextView messageText = (TextView) alert.findViewById(android.R.id.message);
    assert messageText != null;
    messageText.setGravity(Gravity.CENTER);
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

public void handleDateResponse(JSONObject response) {
    horizontalscrollview.setVisibility(View.GONE);
    //Fetch Data From the Services
    JsonParser parser = new JsonParser();
    JsonObject responObj = (JsonObject) parser.parse(response.toString());
    JsonObject profileobj = responObj.get("doctor_profile").getAsJsonObject();

    JsonObject appointment_slot = profileobj.get("appointment_slot").getAsJsonObject();
    JsonArray available_hour = appointment_slot.get("available_hour").getAsJsonArray();

    LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
    String str_timeslot = "", str_phys_avail_id = "";
    if (layout.getChildCount() > 0) {
        layout.removeAllViews();/*from   www.j  a  v  a  2 s. com*/
    }
    timeSlotListMap.clear();

    for (int i = 0; i < available_hour.size(); i++) {
        JsonObject availabilityStatus = available_hour.get(i).getAsJsonObject();
        String str_availabilityStatus = "";

        if (MdliveUtils.checkJSONResponseHasString(availabilityStatus, "status")) {
            str_availabilityStatus = availabilityStatus.get("status").getAsString();
            if (str_availabilityStatus.equals("Available")) {
                //This visibility is for future timeslots response for the corresponding date selection.
                //if  the future date has timeslots then make an appointment req layout nd textview visibility will be gone

                findViewById(R.id.noappmtsTxtLayout).setVisibility(View.GONE);
                reqfutureapptBtnLayout.setVisibility(View.GONE);
                JsonArray timeSlotArray = availabilityStatus.get("time_slot").getAsJsonArray();

                for (int j = 0; j < timeSlotArray.size(); j++) {
                    JsonObject timeSlotObj = timeSlotArray.get(j).getAsJsonObject();

                    if (MdliveUtils.checkJSONResponseHasString(timeSlotObj, "appointment_type")
                            && MdliveUtils.checkJSONResponseHasString(timeSlotObj, "timeslot")) {
                        str_appointmenttype = timeSlotObj.get("appointment_type").getAsString();
                        str_timeslot = timeSlotObj.get("timeslot").getAsString();
                        selectedTimestamp = timeSlotObj.get("timeslot").getAsString();

                        if (MdliveUtils.checkJSONResponseHasString(timeSlotObj, "phys_availability_id")) {
                            str_phys_avail_id = timeSlotObj.get("phys_availability_id").getAsString();
                        } else {
                            str_phys_avail_id = null;
                        }

                        HashMap<String, String> datemap = new HashMap<String, String>();
                        datemap.put("timeslot", str_timeslot);
                        datemap.put("phys_id", str_phys_avail_id);
                        datemap.put("appointment_type", str_appointmenttype);
                        videophoneparentLl.setVisibility(View.VISIBLE);
                        timeSlotListMap.add(datemap);

                        final Button myText = new Button(MDLiveProviderDetails.this);

                        if (str_timeslot.equals("0")) {
                            final int density = (int) getBaseContext().getResources()
                                    .getDisplayMetrics().density;

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                myText.setElevation(0f);
                            }
                            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.WRAP_CONTENT,
                                    LinearLayout.LayoutParams.WRAP_CONTENT);
                            params.setMargins(4 * density, 4 * density, 4 * density, 4 * density);
                            myText.setLayoutParams(params);
                            myText.setGravity(Gravity.CENTER);
                            myText.setTextColor(Color.WHITE);
                            myText.setTextSize(16);
                            myText.setPadding(8 * density, 4 * density, 8 * density, 4 * density);
                            myText.setBackgroundResource(R.drawable.timeslot_white_rounded_corner);
                            myText.setText("Now");
                            myText.setBackgroundResource(R.drawable.timeslot_blue_rounded_corner);
                            myText.setClickable(true);
                            previousSelectedTv = myText;
                            if (str_appointmenttype.toLowerCase().contains("video")
                                    || str_appointmenttype.toLowerCase().contains("video or phone")) {
                                videoList.add(myText);
                            }
                            if (str_appointmenttype.toLowerCase().contains("phone")) {
                                phoneList.add(myText);
                            }

                            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.WRAP_CONTENT,
                                    LinearLayout.LayoutParams.WRAP_CONTENT);
                            lp.setMargins(4 * density, 4 * density, 4 * density, 4 * density);
                            myText.setLayoutParams(lp);
                            myText.setTag("Now");
                            defaultNowTextPreferences(myText, str_appointmenttype);
                            selectedTimeslot = true;
                            clickEventForHorizontalText(myText, str_timeslot, str_phys_avail_id);
                            layout.addView(myText);
                        } else {
                            setHorizontalScrollviewTimeslots(layout, str_timeslot, j, str_phys_avail_id);
                        }
                    }
                }
            } else {
                if (layout.getChildCount() == 0) {
                    selectedTimeslot = false;
                    findViewById(R.id.noappmtsTxtLayout).setVisibility(View.VISIBLE);
                    ((TextView) findViewById(R.id.noAppmtsTxt))
                            .setText(getString(R.string.mdl_notimeslots_txt));
                    reqfutureapptBtnLayout.setVisibility(viewsVisibility);
                    ((TextView) findViewById(R.id.reqfutureapptBtn)).setText("Make an appointment request");
                    ((TextView) findViewById(R.id.reqfutureapptBtn)).setTextColor(Color.parseColor("#0079FD"));
                    videophoneparentLl.setVisibility(View.GONE);
                    tapReqFutureBtnAction();
                    findViewById(R.id.reqApmtBtm).setVisibility(View.GONE);
                }
            }
        }
    }

}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) {

    ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>();

    HashMap<String, APInfoMapItem> apMap = wifi.getAps();
    Set<String> keys = apMap.keySet();
    Iterator<String> iter = keys.iterator();
    while (iter.hasNext()) {
        String bssid = iter.next();
        APInfoMapItem ap = apMap.get(bssid);
        items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets));
    }/*from w  ww .j a v a 2s.  c om*/

    Collections.sort(items);

    table.setColumnCollapsed(0, false);
    table.setColumnCollapsed(1, true);
    table.setColumnShrinkable(0, true);

    for (int i = 0; i < mAddedRows.size(); i++) {
        table.removeView(mAddedRows.get(i));
    }
    mAddedRows.clear();

    int totalCount = wifi.getScanCount();

    Context context = getContext();

    for (WifiViewListItem item : items) {
        TableRow row = new TableRow(context);

        TextView ssidView = new TextView(context);
        ssidView.setText(item.ssid);
        //ssidView.setText("very very very veryvery very very very very very");
        ssidView.setPadding(2, 2, 2, 2);
        ssidView.setTextColor(0xffffffff);

        TextView bssidView = new TextView(context);
        bssidView.setText(item.bssid);
        bssidView.setPadding(2, 2, 2, 2);
        bssidView.setTextColor(0xffffffff);

        TextView cntView = new TextView(context);
        cntView.setText("" + (item.count * 100) / totalCount);
        cntView.setPadding(2, 2, 2, 2);
        cntView.setGravity(Gravity.CENTER);
        cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        TextView rssView = new TextView(context);
        rssView.setText("" + item.rss);
        rssView.setPadding(2, 2, 6, 2);
        rssView.setGravity(Gravity.CENTER);
        rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        row.addView(ssidView, new TableRow.LayoutParams(0));
        row.addView(bssidView, new TableRow.LayoutParams(1));
        row.addView(cntView, new TableRow.LayoutParams(2));
        row.addView(rssView, new TableRow.LayoutParams(3));

        //Log.d(TAG, item.ssid);
        for (int i = 0; i < item.rssBuckets.length; i++) {
            TextView box = new TextView(context);
            box.setText("  ");
            box.setGravity(Gravity.RIGHT);
            box.setPadding(2, 2, 2, 2);
            box.setHeight(15);
            box.setGravity(Gravity.CENTER_VERTICAL);

            float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount());
            //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]);
            int colorValInt = ((int) colorVal) - 1;
            if (colorValInt < 0)
                colorValInt = 0;

            box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan));
            box.setTextColor(0xffffffff);

            row.addView(box, new TableRow.LayoutParams(4 + i));
        }

        row.setGravity(Gravity.CENTER);

        table.addView(row, new TableLayout.LayoutParams());
        table.setColumnStretchable(3, true);
        mAddedRows.add(row);
    }

}

From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
    case ICON_VIEW_TYPE: {
        AppInfo info = mApps.getAdapterItems().get(position).appInfo;
        BubbleTextView icon = (BubbleTextView) holder.mContent;
        icon.applyFromApplicationInfo(info);
        break;/* w  ww  .  j  a va  2  s .c om*/
    }
    case PREDICTION_ICON_VIEW_TYPE: {
        AppInfo info = mApps.getAdapterItems().get(position).appInfo;
        BubbleTextView icon = (BubbleTextView) holder.mContent;
        icon.applyFromApplicationInfo(info);
        break;
    }
    case EMPTY_SEARCH_VIEW_TYPE:
        TextView emptyViewText = (TextView) holder.mContent;
        emptyViewText.setText(mEmptySearchMessage);
        emptyViewText.setGravity(
                mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL);
        break;
    case SEARCH_MARKET_VIEW_TYPE:
        TextView searchView = (TextView) holder.mContent;
        if (mMarketSearchIntent != null) {
            searchView.setVisibility(View.VISIBLE);
            searchView.setContentDescription(mMarketSearchMessage);
            searchView.setGravity(
                    mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL);
            searchView.setText(mMarketSearchMessage);
        } else {
            searchView.setVisibility(View.GONE);
        }
        break;
    }
}

From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java

@Override
public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException {
    // TODO Auto-generated method stub
    mXListView.stopRefresh();//from  w w w. j av  a 2 s .  co m
    if (url.endsWith(ApiInterface.ORDER_INFO)) {

        Message msg = new Message();
        msg.what = MessageConstant.RECEIVE_ORDER_PUSH;
        EventBus.getDefault().post(msg);

        if (jo != null) {
            mOrderEmptyView.setVisibility(View.GONE);
            mOrderEmptyView.setImageDrawable(null);
            mOrderEmptyView.setOnClickListener(null);
            setOrderDetailView(mOrderInfoModel.publicOrder);
        } else {
            mOrderEmptyView.setVisibility(View.VISIBLE);
            mOrderEmptyView.setImageResource(R.drawable.e7_no_connections);
            mOrderEmptyView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    mOrderInfoModel.get(mOrderId);
                }
            });
        }
    } else if (url.endsWith(ApiInterface.ORDER_CANCEL)) {
        ToastView toast = new ToastView(D1_OrderActivity.this, getString(R.string.order_have_canceled));
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
        setOrderDetailView(mOrderInfoModel.publicOrder);
    } else if (url.endsWith(ApiInterface.ORDER_ACCEPT)) {
        orderacceptResponse response = new orderacceptResponse();
        response.fromJson(jo);
        if (response.succeed == 1) {
            showOrderDialog(true, response);
        } else {
            showOrderDialog(false, response);
        }
        setOrderDetailView(mOrderInfoModel.publicOrder);
    } else if (url.endsWith(ApiInterface.ORDER_WORK_DONE)) {
        setOrderDetailView(mOrderInfoModel.publicOrder);
    } else if (url.endsWith(ApiInterface.ORDER_PAY)) {

        if (payCode == ENUM_PAY_CODE.PAY_OFFLINE) {
            AnimationUtil.backAnimationFromBottom(mOrderPlayOrderView);
            mOrderPlayOrderView.setVisibility(View.GONE);
            AnimationUtil.backAnimation(mOrderPlayButtonView);
            mOrderPlayButtonView.setVisibility(View.GONE);
            Handler mHandler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    super.handleMessage(msg);
                    mOrderPlay.setVisibility(View.GONE);
                    mOrderBtnCancel.setVisibility(View.VISIBLE);
                }
            };
            mHandler.sendEmptyMessageDelayed(0, 200);
        } else {
            //Todo 
            ToastView toast = new ToastView(getApplicationContext(), getString(R.string.share_content));
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }

        setOrderDetailView(mOrderInfoModel.publicOrder);
    } else if (url.endsWith(ApiInterface.ORDER_CONFIRM_PAY)) {
        setOrderDetailView(mOrderInfoModel.publicOrder);
    }
}

From source file:com.sssemil.sonyirremote.ir.ir.java

public void onRemoveClick(View view) {
    try {/*from w  ww  .  j  a  v a  2  s  . c  o m*/
        Toast.makeText(this, item, Toast.LENGTH_SHORT).show();

        String[] remove = { "rm", "-rf", irpath + item };
        try {
            Process p = Runtime.getRuntime().exec(remove);
            Log.i("rm", "Waiting... " + irpath + item);
            p.waitFor();
            Log.i("rm", "Done! " + irpath + item);
        } catch (Exception e) {
            Log.e("rm", "Failed! " + irpath + item);
            e.printStackTrace();
        }

        spinner = ((Spinner) findViewById(R.id.spinner));
        localArrayList1 = new ArrayList();
        localArrayList1.remove(item);
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
                localArrayList1);
        dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(dataAdapter);

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.done));
        builder.setMessage(getString(R.string.done_removing) + " " + item + " " + getString(R.string.files));
        builder.setPositiveButton("OK", null);
        AlertDialog dialog = builder.show();

        TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
        messageView.setGravity(Gravity.CENTER);
    } catch (NullPointerException ex) {
        ex.printStackTrace();
        AlertDialog.Builder adb = new AlertDialog.Builder(this);
        adb.setTitle(getString(R.string.error));
        adb.setMessage(getString(R.string.you_need_to_select));
        adb.setIcon(android.R.drawable.ic_dialog_alert);
        adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        adb.show();
    }
}

From source file:com.mobantica.DriverItRide.activities.ActivityProfile.java

private void openDialogSelectLanguange() {
    View lstGroupView = getLayoutInflater().inflate(R.layout.dailog_select_language, null);
    dialogSelectLangunage = new Dialog(this, R.style.MaterialDialogSheet);
    dialogSelectLangunage.setContentView(lstGroupView);
    dialogSelectLangunage.setCancelable(true);
    dialogSelectLangunage.getWindow().setGravity(Gravity.CENTER);
    dialogSelectLangunage.getWindow()/*w  w  w.j  ava  2s.c o  m*/
            .setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    btnSave = (Button) dialogSelectLangunage.findViewById(R.id.btnSave);
    btnSave.setOnClickListener(this);

    rdoEnglish = (RadioButton) dialogSelectLangunage.findViewById(R.id.rdoEnglish);
    rdoHindi = (RadioButton) dialogSelectLangunage.findViewById(R.id.rdoHindi);
    rdoMarathi = (RadioButton) dialogSelectLangunage.findViewById(R.id.rdoMarathi);
    getPreviousLanguageSelected();
    rdoEnglish.setOnCheckedChangeListener(this);
    rdoHindi.setOnCheckedChangeListener(this);
    rdoMarathi.setOnCheckedChangeListener(this);
    dialogSelectLangunage.show();
}

From source file:com.ibm.hellotodoadvanced.MainActivity.java

/**
 * Launches a dialog for updating the TodoItem name. Called when the list item is tapped.
 *
 * @param view The TodoItem that is tapped.
 *///from  w  w  w  .jav  a2 s.  c  o m
public void editTodoName(View view) {
    // Gets position in list view of tapped item
    final Integer position = mListView.getPositionForView(view);
    final Dialog editDialog = new Dialog(this);

    // UI settings for dialog pop-up
    editDialog.setContentView(R.layout.add_edit_dialog);
    editDialog.setTitle("Edit Todo");
    TextView textView = (TextView) editDialog.findViewById(android.R.id.title);
    if (textView != null) {
        textView.setGravity(Gravity.CENTER);
    }
    editDialog.setCancelable(true);
    EditText currentText = (EditText) editDialog.findViewById(R.id.todo);

    // Get selected TodoItem values
    final String name = mTodoItemList.get(position).text;
    final boolean isDone = mTodoItemList.get(position).isDone;
    final int id = mTodoItemList.get(position).idNumber;
    currentText.setText(name);

    Button editDone = (Button) editDialog.findViewById(R.id.Add);
    editDialog.show();

    // When done is pressed, send PUT request to update TodoItem on Bluemix
    editDone.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            EditText editedText = (EditText) editDialog.findViewById(R.id.todo);

            final String updatedName = editedText.getText().toString();

            // If new text is not empty, create JSON with updated info and send PUT request
            if (!updatedName.isEmpty()) {
                String json = "{\"text\":\"" + updatedName + "\",\"isDone\":" + isDone + ",\"id\":" + id + "}";

                // Create PUT REST request using Bluemix Mobile Services SDK and set HTTP headers so Bluemix knows what to expect in the request
                Request request = new Request(bmsClient.getBluemixAppRoute() + "/api/Items", Request.PUT);

                HashMap headers = new HashMap();
                List<String> contentType = new ArrayList<>();
                contentType.add("application/json");
                List<String> accept = new ArrayList<>();
                accept.add("Application/json");

                headers.put("Content-Type", contentType);
                headers.put("Accept", accept);

                request.setHeaders(headers);

                request.send(getApplicationContext(), json, new ResponseListener() {
                    // On success, update local list with updated TodoItem
                    @Override
                    public void onSuccess(Response response) {
                        Log.i(TAG, "Item " + updatedName + " updated successfully");

                        loadList();
                    }

                    // On failure, log errors
                    @Override
                    public void onFailure(Response response, Throwable throwable, JSONObject extendedInfo) {
                        String errorMessage = "";

                        if (response != null) {
                            errorMessage += response.toString() + "\n";
                        }

                        if (throwable != null) {
                            StringWriter sw = new StringWriter();
                            PrintWriter pw = new PrintWriter(sw);
                            throwable.printStackTrace(pw);
                            errorMessage += "THROWN" + sw.toString() + "\n";
                        }

                        if (extendedInfo != null) {
                            errorMessage += "EXTENDED_INFO" + extendedInfo.toString() + "\n";
                        }

                        if (errorMessage.isEmpty())
                            errorMessage = "Request Failed With Unknown Error.";

                        Log.e(TAG, "editTodoName failed with error: " + errorMessage);
                    }
                });

            }
            editDialog.dismiss();
        }
    });
}

From source file:br.com.bioscada.apps.biotracks.TrackListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;/*from   w w  w .  j  a  va 2s. c  o m*/
    switch (item.getItemId()) {
    case R.id.track_list_search:
        return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this);
    case R.id.track_list_start_gps:
        MyTracksLocationManager myTracksLocationManager = new MyTracksLocationManager(this, Looper.myLooper(),
                false);
        if (!myTracksLocationManager.isGpsProviderEnabled()) {
            intent = GoogleLocationUtils.newLocationSettingsIntent(TrackListActivity.this);
            startActivity(intent);
        } else {
            startGps = !TrackRecordingServiceConnectionUtils.isRecordingServiceRunning(this);

            // Show toast
            Toast toast = Toast.makeText(this, startGps ? R.string.gps_starting : R.string.gps_stopping,
                    Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();

            // Invoke trackRecordingService
            if (startGps) {
                trackRecordingServiceConnection.startAndBind();
                bindChangedCallback.run();
            } else {
                ITrackRecordingService trackRecordingService = trackRecordingServiceConnection
                        .getServiceIfBound();
                if (trackRecordingService != null) {
                    try {
                        trackRecordingService.stopGps();
                    } catch (RemoteException e) {
                        Log.e(TAG, "Unable to stop gps.", e);
                    }
                }
                trackRecordingServiceConnection.unbindAndStop();
            }

            // Update menu after starting or stopping gps
            ApiAdapterFactory.getApiAdapter().invalidMenu(this);
        }
        myTracksLocationManager.close();
        return true;
    case R.id.track_list_play_mutliple:
        PlayMultipleDialogFragment.newInstance(-1L).show(getSupportFragmentManager(),
                PlayMultipleDialogFragment.PLAY_MULTIPLE_DIALOG_TAG);
        return true;
    case R.id.track_list_sync_now:
        if (driveSync) {
            SyncUtils.syncNow(this);
        } else {
            new ChooseAccountDialogFragment().show(getSupportFragmentManager(),
                    ChooseAccountDialogFragment.CHOOSE_ACCOUNT_DIALOG_TAG);
        }
        return true;
    case R.id.track_list_aggregated_statistics:
        intent = IntentUtils.newIntent(this, AggregatedStatsActivity.class);
        startActivity(intent);
        return true;
    case R.id.track_list_export_all:
        FileTypeDialogFragment.newInstance(R.id.track_list_export_all, R.string.export_all_title,
                R.string.export_all_option, 4)
                .show(getSupportFragmentManager(), FileTypeDialogFragment.FILE_TYPE_DIALOG_TAG);
        return true;
    case R.id.track_list_import_all:
        FileTypeDialogFragment
                .newInstance(R.id.track_list_import_all, R.string.import_selection_title,
                        R.string.import_selection_option, 2)
                .show(getSupportFragmentManager(), FileTypeDialogFragment.FILE_TYPE_DIALOG_TAG);
        return true;
    case R.id.track_list_delete_all:
        deleteTracks(new long[] { -1L });
        return true;
    case R.id.track_list_settings:
        intent = IntentUtils.newIntent(this, SettingsActivity.class);
        startActivity(intent);
        return true;
    case R.id.track_list_help_feedback:
        intent = IntentUtils.newIntent(this, HelpActivity.class);
        startActivity(intent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:it.crs4.most.ehrlib.WidgetProvider.java

/**
 * Builds the title view.//from   ww w  .  ja va2 s .  c  o m
 *
 * @param context the context
 * @param title the title
 * @return the view
 */
private View buildTitleView(Context context, String title) {
    titleView = new TextView(context);
    titleView.setText(title);
    titleView.setTextColor(Color.WHITE);
    titleView.setTextSize(22);
    titleView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    titleView.setTypeface(null, Typeface.BOLD);
    titleView.setGravity(Gravity.CENTER);

    return titleView;
}