Example usage for android.widget LinearLayout VERTICAL

List of usage examples for android.widget LinearLayout VERTICAL

Introduction

In this page you can find the example usage for android.widget LinearLayout VERTICAL.

Prototype

int VERTICAL

To view the source code for android.widget LinearLayout VERTICAL.

Click Source Link

Usage

From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;/*w w  w.  ja  va 2  s.c o m*/
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

From source file:com.mplayer_remote.ServerList.java

/**
 * Metoda wywoywana przez system Android przy starcie aktywnoci.
 * Tu nastpuje wyczytanie ustawie aplikacji, zainicjowanie GUI aktywnoci, wywietlenie jednego z okien dialogowych dialog_FIRST_TIME_RUNING lub dialog_GIVE_ME_A_APP_PASSWORD 
 * albo odszyfrowanie pliku z zapisan list serwerw (w przypadku gdy metoda onCreate wywoywana jest po restarcie aktywnoci lub gdy aplikacja szyfruje dane domylnym hasem). 
 * @see android.app.Activity#onCreate(android.os.Bundle)
 *///from w w w .jav  a2  s. c om
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //ustawianie GUI
    ScrollView sv = new ScrollView(this);
    ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    TextView text = new TextView(this);
    text.setText(R.string.activity_server_list_title);
    text.setTextSize(18);
    ll.addView(text);
    sv.addView(ll);
    this.setContentView(sv);

    //creating a XML
    Context mContext = getApplicationContext();
    aXMLReaderWriter = new XMLReaderWriter(mContext);

    settingsForAPPSharedPreferences = getSharedPreferences("settings_for_APP", 0);
    isThisFirstRunboolean = settingsForAPPSharedPreferences.getBoolean("is_this_first_run", true);
    isCryptoEnabledboolean = settingsForAPPSharedPreferences.getBoolean("is_crypto_enabled", true); //byo false
    rememberAppPasswordInSesionboolean = settingsForAPPSharedPreferences
            .getBoolean("remember_app_password_in_sesion_boolean", true);

    Log.v(TAG, "aktualny isThisFirstRunboolean: " + isThisFirstRunboolean);
    Log.v(TAG, "aktualny isCryptoEnabledboolean: " + isCryptoEnabledboolean);
    Log.v(TAG, "aktualny rememberAppPasswordInSesionboolean: " + rememberAppPasswordInSesionboolean);
    /*
    Intent intent_from_SettingsForServerList = getIntent(); //getIntent() zwraca obiekt Intent ktry wystartowa Activity
    appPasswordcharArray = intent_from_SettingsForServerList.getCharArrayExtra("app_password");
    */
    if (appPasswordcharArray != null) {
        String appPasswordcharArrayConvertedToString = new String(appPasswordcharArray);
        Log.v(TAG, "Aktuane appPasswordcharArray: " + appPasswordcharArrayConvertedToString);
    }

    if (savedInstanceState != null) {
        serverToEditint = savedInstanceState.getInt("serverToEditint");
        serverToDelete = savedInstanceState.getInt("serverToDelete");
    }
    Object retained = getLastNonConfigurationInstance();
    if (retained != null && retained instanceof StateHolder) { //if onCreate follow configuration change
        mStateHolder = (StateHolder) retained;
    } else {
        mStateHolder = new StateHolder(); //a normal activity start
    }

    //if (rememberAppPasswordInSesionboolean == false){
    //Intent intent_from_SettingsForServerList = getIntent(); //getIntent() zwraca obiekt Intent ktry wystartowa Activity
    //appPasswordcharArray = intent_from_SettingsForServerList.getCharArrayExtra("app_password");
    //}

    if (isThisFirstRunboolean == true && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false) { //if configuration change happens them onResume will show dialog
        Log.v(TAG,
                "(isThisFirstRunboolean == true && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false) ");
        showdialog_FIRST_TIME_RUNING();

    } else if (isCryptoEnabledboolean == true && appPasswordcharArray == null
            && mStateHolder.mIsShowingDialog_GIVE_ME_A_PASSWORD == false && isThisFirstRunboolean == false) {
        //I check isThisFirstRunboolean == false because screen rotation can trigger this on real first app run
        Log.v(TAG,
                "(isCryptoEnabledboolean == true && appPasswordcharArray == null && mStateHolder.mIsShowingDialog_GIVE_ME_A_PASSWORD == false && isThisFirstRunboolean == false)");
        showdialog_GIVE_ME_A_APP_PASSWORD();

    } else if (isCryptoEnabledboolean == true && appPasswordcharArray != null
            && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false) { // I check && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false because screen rotation can trigger this when back form SettingsForAPP
        Log.v(TAG,
                "(isCryptoEnabledboolean == true && appPasswordcharArray != null && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false)");
        try {
            serverListArrayList = aXMLReaderWriter
                    .decryptFileWithXMLAndParseItToServerList(appPasswordcharArray);

            if (serverListArrayList != null) {
                for (int i = 0; i < serverListArrayList.size(); i++) {

                    createConnectButtons(i);

                }
            }
        } catch (WrongPasswordException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } else if (isCryptoEnabledboolean == false) { //isThisFirstRunboolean == false is checked because def values // usunem && isThisFirstRunboolean == false
        Log.v(TAG, "(isCryptoEnabledboolean == false )");
        appPasswordcharArray = "default_password".toCharArray();
        try {
            serverListArrayList = aXMLReaderWriter
                    .decryptFileWithXMLAndParseItToServerList(appPasswordcharArray);

            if (serverListArrayList != null) {
                for (int i = 0; i < serverListArrayList.size(); i++) {

                    createConnectButtonsThatAskForServerPassword(i);

                }
            }

        } catch (WrongPasswordException e) {
            Toast.makeText(getApplicationContext(), R.string.wrong_app_password_exeption, Toast.LENGTH_SHORT)
                    .show();

        }

    }

}

From source file:com.razza.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;//from   ww w  .j a va 2 s  . c  o m
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LogUtils.LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

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

@Override
protected void onCreate(final Bundle savedInstanceState) {
    setupWindow();/*w  w  w . ja  va2 s . c o  m*/
    super.onCreate(savedInstanceState);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
    mResolver = getContentResolver();
    mApplication = TwidereApplication.getInstance(this);
    setContentView(R.layout.activity_sign_in);
    setSupportActionBar((Toolbar) findViewById(R.id.action_bar));

    TwidereActionModeForChildListener actionModeForChildListener = new TwidereActionModeForChildListener(this,
            this, false);
    final TintedStatusNativeActionModeAwareLayout layout = (TintedStatusNativeActionModeAwareLayout) findViewById(
            R.id.main_content);
    layout.setActionModeForChildListener(actionModeForChildListener);

    ThemeUtils.setCompatContentViewOverlay(this, new EmptyDrawable());
    final View actionBarContainer = findViewById(R.id.twidere_action_bar_container);
    ViewCompat.setElevation(actionBarContainer, ThemeUtils.getSupportActionBarElevation(this));
    ViewSupport.setOutlineProvider(actionBarContainer, ViewOutlineProviderCompat.BACKGROUND);
    final View windowOverlay = findViewById(R.id.window_overlay);
    ViewSupport.setBackground(windowOverlay,
            ThemeUtils.getNormalWindowContentOverlay(this, getCurrentThemeResourceId()));

    if (savedInstanceState != null) {
        mAPIUrlFormat = savedInstanceState.getString(Accounts.API_URL_FORMAT);
        mAuthType = savedInstanceState.getInt(Accounts.AUTH_TYPE);
        mSameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL);
        mConsumerKey = trim(savedInstanceState.getString(Accounts.CONSUMER_KEY));
        mConsumerSecret = trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET));
        mUsername = savedInstanceState.getString(Accounts.SCREEN_NAME);
        mPassword = savedInstanceState.getString(Accounts.PASSWORD);
        mAPIChangeTimestamp = savedInstanceState.getLong(EXTRA_API_LAST_CHANGE);
    }

    mUsernamePasswordContainer
            .setVisibility(mAuthType == ParcelableCredentials.AUTH_TYPE_TWIP_O_MODE ? View.GONE : View.VISIBLE);
    mSignInSignUpContainer
            .setOrientation(mAuthType == ParcelableCredentials.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL
                    : LinearLayout.HORIZONTAL);

    mEditUsername.setText(mUsername);
    mEditUsername.addTextChangedListener(this);
    mEditPassword.setText(mPassword);
    mEditPassword.addTextChangedListener(this);
    final Resources resources = getResources();
    final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_green));
    ViewCompat.setBackgroundTintList(mSignInButton, color);
    setSignInButton();
}

From source file:net.henryco.opalette.application.programs.sub.programs.aImage.CanvasSizeControl.java

@Override
protected void onFragmentCreate(View view, AppMainProto context, @Nullable Bundle savedInstanceState) {

    final int fcg = ContextCompat.getColor(context.getActivityContext(), TEXT_COLOR_BLACK_OVERLAY);
    final int fcb = 0xFF000000;

    final float[][] props = { null, { 1, 1 }, { 3, 2 }, { 4, 3 }, { 5, 4 }, { 7, 5 }, { 16, 9 }, { 5, 7 },
            { 4, 5 }, { 3, 4 }, { 2, 3 } };
    final OPallConsumer<float[]> setDimFunc = wh -> {
        int w = (int) Math.floor(wh[0] >= wh[1] ? defScrW : defScrW * (wh[0] / wh[1]));
        int h = (int) Math.floor(wh[0] >= wh[1] ? defScrH * (wh[1] / wh[0]) : defScrH);
        context.getRenderSurface().setSize(w, h).update();
    };//  w  w w  . j  a v a2s.co m

    OPallViewInjector.inject(context.getActivityContext(),
            new OPallViewInjector<AppMainProto>(view, R.layout.canvas_size) {
                @Override
                protected void onInject(AppMainProto context, View view) {

                    final Button[] buttons = { (Button) view.findViewById(R.id.canvasButtonFree),
                            (Button) view.findViewById(R.id.canvasButton1_1),
                            (Button) view.findViewById(R.id.canvasButton3_2),
                            (Button) view.findViewById(R.id.canvasButton4_3),
                            (Button) view.findViewById(R.id.canvasButton5_4),
                            (Button) view.findViewById(R.id.canvasButton7_5),
                            (Button) view.findViewById(R.id.canvasButton16_9),
                            (Button) view.findViewById(R.id.canvasButton5_7),
                            (Button) view.findViewById(R.id.canvasButton4_5),
                            (Button) view.findViewById(R.id.canvasButton3_4),
                            (Button) view.findViewById(R.id.canvasButton2_3) };
                    final TextView[] textViews = { (TextView) view.findViewById(R.id.canvasTextFree),
                            (TextView) view.findViewById(R.id.canvasText1_1),
                            (TextView) view.findViewById(R.id.canvasText3_2),
                            (TextView) view.findViewById(R.id.canvasText4_3),
                            (TextView) view.findViewById(R.id.canvasText5_4),
                            (TextView) view.findViewById(R.id.canvasText7_5),
                            (TextView) view.findViewById(R.id.canvasText16_9),
                            (TextView) view.findViewById(R.id.canvasText5_7),
                            (TextView) view.findViewById(R.id.canvasText4_5),
                            (TextView) view.findViewById(R.id.canvasText3_4),
                            (TextView) view.findViewById(R.id.canvasText2_3), };

                    textViews[actual].setTextColor(fcb);

                    buttons[0].setOnClickListener(
                            v -> OPallAnimated.pressButton75_225(context.getActivityContext(), v, () -> {
                                for (TextView t : textViews)
                                    t.setTextColor(fcg);
                                textViews[0].setTextColor(fcb);
                                actual = 0;

                                OPallFunction<String, Integer> getStringFunc = integer -> context
                                        .getActivityContext().getResources().getString(integer);

                                LinearLayout layout = new LinearLayout(context.getActivityContext());
                                layout.setOrientation(LinearLayout.VERTICAL);

                                InjectableSeekBar wBar = new InjectableSeekBar(layout,
                                        getStringFunc.apply(R.string.width));
                                InjectableSeekBar hBar = new InjectableSeekBar(layout,
                                        getStringFunc.apply(R.string.height));
                                wBar.setMax((int) defScrW)
                                        .onBarCreate(b -> b.setProgress(context.getRenderSurface().getWidth()));
                                hBar.setMax((int) defScrH).onBarCreate(
                                        b -> b.setProgress(context.getRenderSurface().getHeight()));
                                OPallViewInjector.inject(context.getActivityContext(), hBar, wBar);

                                new OPallAlertDialog().title(getStringFunc.apply(R.string.set_canvas_size))
                                        .message("").content(layout)
                                        .negative(getStringFunc.apply(R.string.cancel))
                                        .positive(getStringFunc.apply(R.string.apply), () -> {
                                            context.getRenderSurface().setSize(
                                                    (int) clamp(wBar.getProgress(), defScrW, MIN_SIZE),
                                                    (int) clamp(hBar.getProgress(), defScrW, MIN_SIZE));
                                            context.getRenderSurface().update();
                                        }).neutral(getStringFunc.apply(R.string.control_top_bar_button_reset),
                                                () -> {
                                                    context.getRenderSurface().setSize((int) defScrW,
                                                            (int) defScrW);
                                                    context.getRenderSurface().update();
                                                })
                                        .show(context.getActivityContext().getSupportFragmentManager(),
                                                "Canvas size dialog");
                            }));
                    for (int i = 1; i < buttons.length; i++) {
                        final int k = i;
                        buttons[i].setOnClickListener(
                                v -> OPallAnimated.pressButton75_225(context.getActivityContext(), v, () -> {
                                    actual = k;
                                    setDimFunc.consume(props[k]);
                                    textViews[0].setTextColor(fcg);
                                    for (TextView t : textViews)
                                        t.setTextColor(t == textViews[k] ? fcb : fcg);
                                }));
                    }

                }
            });

}

From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java

public void verifyAccount() {
    final AlertDialog builder = new AlertDialog.Builder(this, R.style.InvitationDialog)
            .setPositiveButton("Done", null).setNegativeButton("Cancel", null).create();

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText emailBox = new EditText(this);
    emailBox.setTextColor(getResources().getColor(R.color.icons));
    emailBox.setHintTextColor(getResources().getColor(R.color.icons));
    emailBox.setHint("Email");
    layout.addView(emailBox);/* ww  w .  j  av  a 2  s . c o  m*/

    final EditText codeBox = new EditText(this);
    codeBox.setTextColor(getResources().getColor(R.color.icons));
    codeBox.setHintTextColor(getResources().getColor(R.color.icons));
    codeBox.setHint("Code");
    layout.addView(codeBox);

    builder.setView(layout);

    //      final EditText etNickName = new EditText(this);
    //      etNickName.setTextColor(Color.parseColor("#FFFFFF"));
    //      builder.setView(etNickName);
    builder.setTitle("Verify registration");

    builder.setMessage("Enter emailId and code to activate account");

    builder.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            final Button btnAccept = builder.getButton(AlertDialog.BUTTON_POSITIVE);
            btnAccept.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (emailBox.getText().toString().isEmpty() && codeBox.getText().toString().isEmpty()) {
                        Toast.makeText(getApplicationContext(), "Fields cannot be empty", Toast.LENGTH_SHORT)
                                .show();
                    } else {
                        verifyApi(emailBox.getText().toString(), codeBox.getText().toString());
                        builder.dismiss();
                    }
                }
            });

            final Button btnDecline = builder.getButton(DialogInterface.BUTTON_NEGATIVE);
            btnDecline.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    builder.dismiss();
                }
            });
        }
    });

    builder.show();

}

From source file:com.citrus.sample.UIActivity.java

private void promptAutoLoadSubscription() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(UIActivity.this);
    String message = null;/*from  w  w w .  j a  v a  2s  . co m*/
    String positiveButtonText = "Yes";

    LinearLayout linearLayout = new LinearLayout(UIActivity.this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    alert.setTitle("Enable Auto-Load?");
    alert.setMessage(getString(R.string.auto_load_message));

    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction()
                    .setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
                    .replace(R.id.container, AutoLoadFragment.newInstance());
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

    alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });
    alert.show();
}

From source file:com.sft.blackcatapp.SearchCoachActivity.java

private void showOpenCityPopupWindow(View parent) {
    if (openCityPopupWindow == null) {
        LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null);
        popWindowLayout.removeAllViews();
        // LinearLayout popWindowLayout = new LinearLayout(mContext);
        popWindowLayout.setOrientation(LinearLayout.VERTICAL);
        ListView OpenCityListView = new ListView(mContext);
        OpenCityListView.setDividerHeight(0);
        OpenCityListView.setCacheColorHint(android.R.color.transparent);
        OpenCityListView.setOnItemClickListener(new OnItemClickListener() {

            @Override//from w w w.  j  av  a  2 s .c  o  m
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                OpenCityVO selectCity = openCityList.get(position);
                System.out.println(selectCity.getName());
                cityname = selectCity.getName().replace("", "");
                licensetype = "";
                coachname = "";
                ordertype = "0";
                index = 1;
                obtainCaoch();
                openCityPopupWindow.dismiss();
                openCityPopupWindow = null;
            }
        });
        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        popWindowLayout.addView(OpenCityListView, param);
        OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList);
        OpenCityListView.setAdapter(openCityAdapter);

        openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT);
    }
    openCityPopupWindow.setFocusable(true);
    openCityPopupWindow.setOutsideTouchable(true);
    // Back???
    openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable());

    openCityPopupWindow.showAsDropDown(parent);
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCashoutPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter account details.";
    String positiveButtonText = "Withdraw";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelAmount = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAccountNo = new TextView(getActivity());
    final EditText editAccountNo = new EditText(getActivity());
    editAccountNo.setSingleLine(true);//from   www  .j  a va  2s.c  o  m
    final TextView labelAccountHolderName = new TextView(getActivity());
    final EditText editAccountHolderName = new EditText(getActivity());
    editAccountHolderName.setSingleLine(true);
    final TextView labelIfscCode = new TextView(getActivity());
    final EditText editIfscCode = new EditText(getActivity());
    editIfscCode.setSingleLine(true);

    labelAmount.setText("Withdrawal Amount");
    labelAccountNo.setText("Account Number");
    labelAccountHolderName.setText("Account Holder Name");
    labelIfscCode.setText("IFSC Code");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelAmount.setLayoutParams(layoutParams);
    labelAccountNo.setLayoutParams(layoutParams);
    labelAccountHolderName.setLayoutParams(layoutParams);
    labelIfscCode.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    editAccountNo.setLayoutParams(layoutParams);
    editAccountHolderName.setLayoutParams(layoutParams);
    editIfscCode.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAccountNo);
    linearLayout.addView(editAccountNo);
    linearLayout.addView(labelAccountHolderName);
    linearLayout.addView(editAccountHolderName);
    linearLayout.addView(labelIfscCode);
    linearLayout.addView(editIfscCode);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

    alert.setTitle("Withdraw Money To Your Account");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editAmount.getText().toString();
            String accontNo = editAccountNo.getText().toString();
            String accountHolderName = editAccountHolderName.getText().toString();
            String ifsc = editIfscCode.getText().toString();

            CashoutInfo cashoutInfo = new CashoutInfo(new Amount(amount), accontNo, accountHolderName, ifsc);
            mListener.onCashoutSelected(cashoutInfo);

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editAmount.requestFocus();
    alert.show();
}

From source file:com.facebook.android.friendsmash.ScoreboardFragment.java

private void populateScoreboard() {
    // Ensure all components are firstly removed from scoreboardContainer
    scoreboardContainer.removeAllViews();

    // Ensure the progress spinner is hidden
    progressContainer.setVisibility(View.INVISIBLE);

    // Ensure scoreboardEntriesList is not null and not empty first
    if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) {
        closeAndShowError(getResources().getString(R.string.error_no_scores));
    } else {/*www. j  ava  2s. c  o m*/
        // Iterate through scoreboardEntriesList, creating new UI elements for each entry
        int index = 0;
        Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator();
        while (scoreboardEntriesIterator.hasNext()) {
            // Get the current scoreboard entry
            final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next();

            // FrameLayout Container for the currentScoreboardEntry ...

            // Create and add a new FrameLayout to display the details of this entry
            FrameLayout frameLayout = new FrameLayout(getActivity());
            scoreboardContainer.addView(frameLayout);

            // Set the attributes for this frameLayout
            int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin);
            frameLayout.setPadding(0, topPadding, 0, 0);

            // ImageView background image ...
            {
                // Create and add an ImageView for the background image to this entry
                ImageView backgroundImageView = new ImageView(getActivity());
                frameLayout.addView(backgroundImageView);

                // Set the image of the backgroundImageView
                String uri = "drawable/scores_stub_even";
                if (index % 2 != 0) {
                    // Odd entry
                    uri = "drawable/scores_stub_odd";
                }
                int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName());
                Drawable image = getResources().getDrawable(imageResource);
                backgroundImageView.setImageDrawable(image);

                // Other attributes of backgroundImageView to modify
                FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
                int backgroundImageViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top);
                backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0);
                backgroundImageViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    backgroundImageViewLayoutParams.gravity = Gravity.RIGHT;
                }
                backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams);
            }

            // ProfilePictureView of the current user ...
            {
                // Create and add a ProfilePictureView for the current user entry's profile picture
                ProfilePictureView profilePictureView = new ProfilePictureView(getActivity());
                frameLayout.addView(profilePictureView);

                // Set the attributes of the profilePictureView
                int profilePictureViewWidth = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width);
                FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams(
                        profilePictureViewWidth, profilePictureViewWidth);
                int profilePictureViewMarginLeft = 0;
                int profilePictureViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top);
                int profilePictureViewMarginRight = 0;
                int profilePictureViewMarginBottom = 0;
                if (index % 2 == 0) {
                    profilePictureViewMarginLeft = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left);
                } else {
                    profilePictureViewMarginRight = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right);
                }
                profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft,
                        profilePictureViewMarginTop, profilePictureViewMarginRight,
                        profilePictureViewMarginBottom);
                profilePictureViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    profilePictureViewLayoutParams.gravity = Gravity.RIGHT;
                }
                profilePictureView.setLayoutParams(profilePictureViewLayoutParams);

                // Finally set the id of the user to show their profile pic
                profilePictureView.setProfileId(currentScoreboardEntry.getId());
            }

            // LinearLayout to hold the text in this entry

            // Create and add a LinearLayout to hold the TextViews
            LinearLayout textViewsLinearLayout = new LinearLayout(getActivity());
            frameLayout.addView(textViewsLinearLayout);

            // Set the attributes for this textViewsLinearLayout
            FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
            int textViewsLinearLayoutMarginLeft = 0;
            int textViewsLinearLayoutMarginTop = getResources()
                    .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top);
            int textViewsLinearLayoutMarginRight = 0;
            int textViewsLinearLayoutMarginBottom = 0;
            if (index % 2 == 0) {
                textViewsLinearLayoutMarginLeft = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left);
            } else {
                textViewsLinearLayoutMarginRight = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right);
            }
            textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft,
                    textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight,
                    textViewsLinearLayoutMarginBottom);
            textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT;
            if (index % 2 != 0) {
                // Odd entry
                textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT;
            }
            textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams);
            textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL);

            // TextView with the position and name of the current user
            {
                // Set the text that should go in this TextView first
                int position = index + 1;
                String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName();

                // Create and add a TextView for the current user position and first name
                TextView titleTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(titleTextView);

                // Set the text and other attributes for this TextView
                titleTextView.setText(currentScoreboardEntryTitle);
                titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont);
            }

            // TextView with the score of the current user
            {
                // Create and add a TextView for the current user score
                TextView scoreTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(scoreTextView);

                // Set the text and other attributes for this TextView
                scoreTextView.setText("Score: " + currentScoreboardEntry.getScore());
                scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont);
            }

            // Finally make this frameLayout clickable so that a game starts with the user smashing
            // the user represented by this frameLayout in the scoreContainer
            frameLayout.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_UP) {
                        Bundle bundle = new Bundle();
                        bundle.putString("user_id", currentScoreboardEntry.getId());

                        Intent i = new Intent();
                        i.putExtras(bundle);

                        getActivity().setResult(Activity.RESULT_FIRST_USER, i);
                        getActivity().finish();
                        return false;
                    } else {
                        return true;
                    }
                }

            });

            // Increment the index before looping back
            index++;
        }
    }
}