Example usage for android.content.res Resources getConfiguration

List of usage examples for android.content.res Resources getConfiguration

Introduction

In this page you can find the example usage for android.content.res Resources getConfiguration.

Prototype

public Configuration getConfiguration() 

Source Link

Document

Return the current configuration that is in effect for this resource object.

Usage

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        for (int i = 0, count = fm.getBackStackEntryCount(); i < count; i++) {
            fm.popBackStackImmediate();/* w  w w . j av a2  s. c om*/
        }
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:org.mariotaku.twidere.activity.support.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        // for (int i = 0, count = fm.getBackStackEntryCount(); i < count;
        // i++) {
        // fm.popBackStackImmediate();
        // }//from  ww  w.  j  a  v  a 2s  . co  m
        fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:github.madmarty.madsonic.util.Util.java

public static void changeLanguage(Context context) {

    Resources res = context.getResources();
    DisplayMetrics dm = res.getDisplayMetrics();

    android.content.res.Configuration conf = res.getConfiguration();

    SharedPreferences prefs = getPreferences(context);
    String appLanguage = prefs.getString(Constants.PREFERENCES_KEY_LANGUAGE, "us");

    if ("auto".equalsIgnoreCase(appLanguage)) {
        conf.locale = new Locale("en");
        res.updateConfiguration(conf, dm);
    } else {/*from ww  w  .  j  a va2  s .  com*/
        conf.locale = new Locale(appLanguage);
        res.updateConfiguration(conf, dm);
    }
}

From source file:abanoubm.dayra.main.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (Utility.getArabicLang(getApplicationContext()) == 1) {
        Utility.setArabicLang(getApplicationContext(), 2);

        Locale myLocale = new Locale("ar");
        Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;//w  w  w  .  j  a va2s .c  om
        res.updateConfiguration(conf, dm);

        finish();
        startActivity(new Intent(getIntent()));
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_main);
    ((TextView) findViewById(R.id.subhead1)).setText(R.string.app_name);
    ((TextView) findViewById(R.id.subhead2)).setText(BuildConfig.VERSION_NAME);
    findViewById(R.id.nav_back).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();

        }
    });
    ((TextView) findViewById(R.id.footer)).setText("dayra " + BuildConfig.VERSION_NAME + " @"
            + new SimpleDateFormat("yyyy", Locale.getDefault()).format(new Date()) + " Abanoub M.");

    if (!Utility.getDayraName(getApplicationContext()).equals("")) {
        startActivity(new Intent(getApplicationContext(), Home.class));
        finish();
    }

    ListView lv = (ListView) findViewById(R.id.home_list);

    mMenuItemAdapter = new MenuItemAdapter(getApplicationContext(),
            new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.sign_menu))), 1);
    lv.setAdapter(mMenuItemAdapter);

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                sign();
                break;
            case 1:
                register();
                break;
            case 2:
                if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this,
                        Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                    importDB();
                } else {
                    ActivityCompat.requestPermissions(Main.this,
                            new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, IMPORT_REQUEST);
                }
                break;
            case 3:
                startActivity(new Intent(Intent.ACTION_VIEW).setData(
                        Uri.parse("https://drive.google.com/file/d/0B1rNCm5K9cvwVXJTTzNqSFdrVk0/view")));
                break;
            case 4:
                startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(
                        "https://drive.google.com/open?id=1flSRdoiIT_hNd96Kxz3Ww3EhXDLZ45FhwFJ2hF9vl7g")));
                break;
            case 5: {

                AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
                builder.setTitle(R.string.label_choose_language);
                builder.setItems(getResources().getStringArray(R.array.language_menu),
                        new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String temp;
                                if (which == 1) {
                                    temp = "en";
                                    Utility.setArabicLang(getApplicationContext(), 0);
                                } else {
                                    temp = "ar";
                                    Utility.setArabicLang(getApplicationContext(), 2);
                                }
                                Locale myLocale = new Locale(temp);
                                Resources res = getResources();
                                DisplayMetrics dm = res.getDisplayMetrics();
                                Configuration conf = res.getConfiguration();
                                conf.locale = myLocale;
                                res.updateConfiguration(conf, dm);

                                finish();
                                startActivity(new Intent(getIntent()));
                            }

                        });
                builder.create().show();

            }
                break;
            case 6:
                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/453595434816965"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/dayraapp"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;

            case 7:

                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/1363784786"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (Exception e) {
                    startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/EngineeroBono"))
                                    .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;
            case 8:
                Uri uri = Uri.parse("market://details?id=" + getPackageName());
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                try {
                    startActivity(goToMarket);
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
                }
                break;
            case 9:
                if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this,
                        android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                    Intent intent = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.setDataAndType(Uri.fromFile(new File(Utility.getDayraFolder())), "*/*");
                    startActivity(
                            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } else {
                    ActivityCompat.requestPermissions(Main.this,
                            new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
                            FOLDER_REQUEST);
                }
                break;
            case 10:
                LayoutInflater li = LayoutInflater.from(getApplicationContext());
                final View aboutView = li.inflate(R.layout.dialogue_about, null, false);
                final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create();
                ad.setView(aboutView, 0, 0, 0, 0);
                ad.show();
                ((TextView) aboutView.findViewById(R.id.about))
                        .setText(String.format(getResources().getString(R.string.copyright),
                                Calendar.getInstance().get(Calendar.YEAR)));

                ((TextView) aboutView.findViewById(R.id.notice)).setText(GoogleApiAvailability.getInstance()
                        .getOpenSourceSoftwareLicenseInfo(getApplicationContext()));
                aboutView.findViewById(R.id.btn).setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        ad.cancel();
                    }
                });
                break;
            }
        }
    });

}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getResources();
    boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortrait) {
        mColumnWidth = (int) (res.getDisplayMetrics().widthPixels * 0.87);
    } else {/*w  w w  . j a  va 2 s . com*/
        mColumnWidth = (int) (res.getDisplayMetrics().density * 320);
    }

    mGestureDetector = new GestureDetector(getContext(), new GestureListener());
    mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f));
    mAutoScroller = new AutoScroller(getContext(), this);
    mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN
            : AutoScroller.AutoScrollMode.POSITION);
    mDragItem = new DragItem(getContext());

    mRootLayout = new FrameLayout(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    mColumnLayout = new LinearLayout(getContext());
    mColumnLayout.setOrientation(LinearLayout.HORIZONTAL);
    mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mColumnLayout.setMotionEventSplittingEnabled(false);

    mRootLayout.addView(mColumnLayout);
    mRootLayout.addView(mDragItem.getDragItemView());
    addView(mRootLayout);
}

From source file:com.miuhouse.yourcompany.student.view.widget.date.datepicker.DayPickerView.java

public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(SUtils.createThemeWrapper(context, R.attr.sublimePickerStyle, R.style.SublimePickerStyleLight,
            defStyleAttr, R.style.DayPickerViewStyle), attrs);

    context = getContext();//from   www. ja v  a  2 s .  c  o  m

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DayPickerView, defStyleAttr,
            R.style.DayPickerViewStyle);

    final int monthTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spMonthTextAppearance,
            R.style.SPMonthLabelTextAppearance);
    // verified
    final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spWeekDayTextAppearance,
            R.style.SPWeekDayLabelTextAppearance);
    // verified
    final int dayTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spDateTextAppearance,
            R.style.SPDayTextAppearance);

    final ColorStateList daySelectorColor = a.getColorStateList(R.styleable.DayPickerView_spDaySelectorColor);

    a.recycle();

    if (Config.DEBUG) {
        Log.i(TAG, "MDayPickerView_spmMonthTextAppearance: " + monthTextAppearanceResId);
        Log.i(TAG, "MDayPickerView_spmWeekDayTextAppearance: " + dayOfWeekTextAppearanceResId);
        Log.i(TAG, "MDayPickerView_spmDateTextAppearance: " + dayTextAppearanceResId);
    }

    String titleFormat;
    final Resources res = getContext().getResources();

    final Locale locale = res.getConfiguration().locale;
    if (SUtils.isApi_18_OrHigher()) {
        titleFormat = DateFormat.getBestDateTimePattern(locale, "MM");
    } else {
        titleFormat = DateTimePatternHelper.getBestDateTimePattern(locale, DateTimePatternHelper.PATTERN_MMMMy);
    }

    mTitleFormatter = new SimpleDateFormat(titleFormat, locale);

    // Set up adapter.
    mAdapter = new DayPickerPagerAdapter(context, R.layout.date_picker_month_item, R.id.month_view, this);
    mAdapter.setMonthTextAppearance(monthTextAppearanceResId);
    mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId);
    mAdapter.setDayTextAppearance(dayTextAppearanceResId);
    mAdapter.setDaySelectorColor(daySelectorColor);

    final LayoutInflater inflater = LayoutInflater.from(context);

    int layoutIdToUse, viewPagerIdToUse;

    if (getTag() != null && getTag() instanceof String
            && getResources().getString(R.string.recurrence_end_date_picker_tag).equals(getTag())) {
        layoutIdToUse = R.layout.day_picker_content_redp;
        viewPagerIdToUse = R.id.redp_view_pager;
    } else {
        layoutIdToUse = R.layout.day_picker_content_sdp;
        viewPagerIdToUse = R.id.sdp_view_pager;
    }

    inflater.inflate(layoutIdToUse, this, true);

    OnClickListener onClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            int direction = -1;
            if (v == mPrevButton) {
                direction = -1;
            } else if (v == mNextButton) {
                direction = 1;
            } else if (v == tvReset) {
                if (mOnResetClickListener != null)
                    mOnResetClickListener.onResetClick();
                //                    return;
            }

            // Animation is expensive for accessibility services since it sends
            // lots of scroll and content change events.
            final boolean animate = !mAccessibilityManager.isEnabled();

            // ViewPager clamps input values, so we don't need to worry
            // about passing invalid indices.
            final int nextItem = mViewPager.getCurrentItem() + direction;
            mViewPager.setCurrentItem(nextItem, animate);
        }
    };

    mPrevButton = (TextView) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(onClickListener);

    mNextButton = (TextView) findViewById(R.id.next);
    mNextButton.setOnClickListener(onClickListener);
    mPrevButton.setText(getTitle());
    mNextButton.setText(getNextTitle());
    tvReset = (TextView) findViewById(R.id.tv_reset);
    tvReset.setOnClickListener(onClickListener);
    ViewPager.OnPageChangeListener onPageChangedListener = new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            final float alpha = Math.abs(0.5f - positionOffset) * 2.0f;
            //                mPrevButton.setAlpha(alpha);
            //                mNextButton.setAlpha(alpha);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageSelected(int position) {
            Log.i("TAG", "position=" + position);
            mOnPageClickListener.onPageSelected(position);
            updateButtonVisibility(position);
        }
    };

    mViewPager = (DayPickerViewPager) findViewById(viewPagerIdToUse);
    mViewPager.setAdapter(mAdapter);

    mViewPager.addOnPageChangeListener(onPageChangedListener);

    // Proxy the month text color into the previous and next buttons.
    if (monthTextAppearanceResId != 0) {
        final TypedArray ta = context.obtainStyledAttributes(null, ATTRS_TEXT_COLOR, 0,
                monthTextAppearanceResId);
        final ColorStateList monthColor = ta.getColorStateList(0);

        ta.recycle();
    }

    // Proxy selection callbacks to our own listener.
    mAdapter.setDaySelectionEventListener(new DayPickerPagerAdapter.DaySelectionEventListener() {
        @Override
        public boolean onDaySelected(SimpleMonthView view, Calendar day) {
            if (mProxyDaySelectionEventListener != null) {
                return mProxyDaySelectionEventListener.onDaySelected(view, day);
            }
            return true;
        }

        @Override
        public void onDateRangeSelectionStarted(@NonNull SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionStarted(selectedDate);
            }
        }

        @Override
        public void onDateRangeSelectionEnded(@Nullable SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionEnded(selectedDate);
            }
        }

        @Override
        public void onDateRangeSelectionUpdated(@NonNull SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionUpdated(selectedDate);
            }
        }
    });
}

From source file:com.duinopeak.balanbot.BalanbotActivity.java

@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    if (D)//from  w  w  w  .  j a va 2s  .co  m
        Log.d(TAG, "onTabSelected: " + tab.getPosition());
    currentTabSelected = tab.getPosition();

    Resources mResources = getResources();
    if (mResources.getBoolean(R.bool.isTablet)
            && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
            && currentTabSelected == ViewPagerAdapter.INFO_FRAGMENT) { // Check if the last tab is selected in landscape mode
        currentTabSelected -= 1; // If so don't go any further
        ActionBar bar = getSupportActionBar();
        bar.selectTab(bar.getTabAt(currentTabSelected));
    }

    mUnderlinePageIndicator.setCurrentItem(currentTabSelected); // When the given tab is selected, switch to the corresponding page in the ViewPager
    CustomViewPager.setPagingEnabled(true);
    if (checkTab(ViewPagerAdapter.GRAPH_FRAGMENT) && mChatService != null) {
        if (mChatService.getState() == BluetoothChatService.STATE_CONNECTED) {
            mChatService.write(getKalman);
            if (GraphFragment.mToggleButton != null) {
                if (GraphFragment.mToggleButton.isChecked())
                    mChatService.write(imuBegin); // Request data
                else
                    mChatService.write(imuStop); // Stop sending data
            }
        }
    } else if (checkTab(ViewPagerAdapter.INFO_FRAGMENT) && mChatService != null) {
        if (mChatService.getState() == BluetoothChatService.STATE_CONNECTED) {
            mChatService.write(getInfo); // Update info
            if (InfoFragment.mToggleButton != null) {
                if (InfoFragment.mToggleButton.isChecked())
                    mChatService.write(statusBegin); // Request data
                else
                    mChatService.write(statusStop); // Stop sending data
            }
        }
    }
    if (!checkTab(ViewPagerAdapter.GRAPH_FRAGMENT)) { // Needed when the user rotates the screen
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard
        imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0);
    }
}

From source file:ubc.cs.cpsc210.sustainabilityapp.UBCSustainabilityAppActivity.java

/**
 * Set up tabs/*from   w  w w  . ja v a2 s. com*/
 * 
 * @param res   the application's resources
 */
private void setupTabs(Resources res) {
    mTabManager = new TabManager(this, mTabHost, R.id.realtabcontent);

    mTabManager.addTab(mTabHost.newTabSpec(POI).setIndicator("POIs", res.getDrawable(R.drawable.ic_tab_poi)),
            POIFragment.class, null);
    mTabManager.addTab(
            mTabHost.newTabSpec(FEATURE).setIndicator("Features", res.getDrawable(R.drawable.ic_tab_feature)),
            FeatureFragment.class, null);

    // add MapDisplayFragment to tabs only in portrait mode
    if (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        Fragment mapFragment = getSupportFragmentManager().findFragmentByTag(MAP);

        if (mapFragment != null) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.remove(mapFragment);
            ft.commit();
            getSupportFragmentManager().executePendingTransactions();
            mTabManager.addTab(
                    mTabHost.newTabSpec(MAP).setIndicator("Map", res.getDrawable(R.drawable.ic_tab_map)),
                    mapFragment, null);
        } else
            mTabManager.addTab(
                    mTabHost.newTabSpec(MAP).setIndicator("Map", res.getDrawable(R.drawable.ic_tab_map)),
                    MapDisplayFragment.class, null);
    }
}

From source file:com.woxthebox.draglistview.KanbanBoardView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getResources();
    boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortrait) {
        mColumnWidth = (int) (res.getDisplayMetrics().widthPixels);
    } else {//from  ww w .  j av a 2s  .  c  om
        mColumnWidth = (int) (res.getDisplayMetrics().density * 320);
    }

    mGestureDetector = new GestureDetector(getContext(), new GestureListener());
    mColumnGestureListener = new ColumnGestureListener();
    mColumnGestureDetector = new GestureDetector(getContext(), mColumnGestureListener);
    mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f));
    mAutoScroller = new AutoScroller(getContext(), this);
    mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN
            : AutoScroller.AutoScrollMode.POSITION);
    mDragItem = new DragItem(getContext());

    mRootLayout = new FrameLayout(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    mColumnLayout = new LinearLayout(getContext());
    mColumnLayout.setOrientation(LinearLayout.HORIZONTAL);
    mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mColumnLayout.setMotionEventSplittingEnabled(false);

    mRootLayout.addView(mColumnLayout);
    mRootLayout.addView(mDragItem.getDragItemView());
    addView(mRootLayout);
}

From source file:org.pluroid.pluroium.PlurkHelper.java

/**
 * Add a plurk// w  w  w . j  ava 2 s . c  o  m
 */
public boolean addPlurk(String qualifier, String content, boolean allowComment) {
    boolean result = false;

    try {
        HttpPost post = new HttpPost(getApiUri(ADD_PLURK_URL));
        Resources res = context.getResources();
        Configuration conf = res.getConfiguration();

        String lang = "en";
        if (conf.locale == Locale.TAIWAN) {
            lang = "tr_ch";
        }

        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("api_key", API_KEY));
        params.add(new BasicNameValuePair("qualifier", qualifier));
        params.add(new BasicNameValuePair("lang", lang));
        params.add(new BasicNameValuePair("content", content));

        post.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
        HttpResponse resp = httpClient.execute(post);
        int status = resp.getStatusLine().getStatusCode();

        if (status == HttpStatus.SC_OK) {
            result = true;
        }

    } catch (Exception e) {
        Log.e(TAG, "Add plurk error: ", e);
    } finally {
        connMgr.shutdown();
    }

    return result;
}