Example usage for android.widget LinearLayout setBackgroundColor

List of usage examples for android.widget LinearLayout setBackgroundColor

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:org.vshgap.ui.Components.EmojiView.java

public EmojiView(boolean needStickers, Context context) {
    super(context);
    SharedPreferences themePrefs = ApplicationLoader.applicationContext
            .getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int bgColor = themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7);
    int tabColor = themePrefs.getInt("chatEmojiViewTabColor",
            AndroidUtilities.getIntDarkerColor("themeColor", -0x15));
    int lineColor = bgColor == 0xfff5f6f7 ? 0xffe2e5e7 : AndroidUtilities.setDarkColor(bgColor, 0x10);
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(context);
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {/*from  w ww  .j a v a  2s.  c om*/
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(emojiGridAdapter);
        //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor);
        adapters.add(emojiGridAdapter);
    }

    if (needStickers) {
        GridView gridView = new GridView(context);
        gridView.setColumnWidth(AndroidUtilities.dp(72));
        gridView.setNumColumns(-1);
        gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0);
        gridView.setClipToPadding(false);
        views.add(gridView);
        stickersGridAdapter = new StickersGridAdapter(context);
        gridView.setAdapter(stickersGridAdapter);
        //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor);
    }

    //setBackgroundColor(0xfff5f6f7);
    setBackgroundColor(bgColor);

    pager = new ViewPager(context);
    pager.setAdapter(new EmojiPagesAdapter());

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    //linearLayout.setBackgroundColor(0xfff5f6f7);
    linearLayout.setBackgroundColor(bgColor);
    addView(linearLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtilities.dp(48)));

    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(context);
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorHeight(AndroidUtilities.dp(2));
    tabs.setUnderlineHeight(AndroidUtilities.dp(1));
    //tabs.setIndicatorColor(0xff2b96e2);
    tabs.setIndicatorColor(tabColor);
    //tabs.setUnderlineColor(0xffe2e5e7);
    tabs.setUnderlineColor(lineColor);
    linearLayout.addView(tabs, new LinearLayout.LayoutParams(0, AndroidUtilities.dp(48), 1.0f));

    FrameLayout frameLayout = new FrameLayout(context);
    linearLayout.addView(frameLayout,
            new LinearLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48)));

    backspaceButton = new ImageView(context) {
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                backspacePressed = true;
                backspaceOnce = false;
                postBackspaceRunnable(350);
            } else if (event.getAction() == MotionEvent.ACTION_CANCEL
                    || event.getAction() == MotionEvent.ACTION_UP) {
                backspacePressed = false;
                if (!backspaceOnce) {
                    if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) {
                        backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
                    }
                }
            }
            super.onTouchEvent(event);
            return true;
        }
    };
    backspaceButton.setImageResource(R.drawable.ic_smiles_backspace);
    backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace);
    backspaceButton.setScaleType(ImageView.ScaleType.CENTER);
    frameLayout.addView(backspaceButton,
            new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48)));

    View view = new View(context);
    //view.setBackgroundColor(0xffe2e5e7);
    view.setBackgroundColor(lineColor);
    frameLayout.addView(view, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(1),
            Gravity.LEFT | Gravity.BOTTOM));

    recentsWrap = new FrameLayout(context);
    recentsWrap.addView(views.get(0));

    TextView textView = new TextView(context);
    textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    textView.setTextSize(18);
    textView.setTextColor(0xff888888);
    textView.setGravity(Gravity.CENTER);
    recentsWrap.addView(textView);
    views.get(0).setEmptyView(textView);

    addView(pager);

    loadRecents();

    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }

}

From source file:net.ustyugov.jtalk.activity.vcard.VCardActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    service = JTalkService.getInstance();
    account = getIntent().getStringExtra("account");
    jid = getIntent().getStringExtra("jid");
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);
    setContentView(R.layout.paged_activity);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle("vCard");
    getActionBar().setSubtitle(jid);// w w  w.j a v a2s .  c om

    if (service.getConferencesHash(account).containsKey(StringUtils.parseBareAddress(jid))) {
        Presence p = service.getConferencesHash(account).get(StringUtils.parseBareAddress(jid))
                .getOccupantPresence(jid);
        if (p != null) {
            MUCUser mucUser = (MUCUser) p.getExtension("x", "http://jabber.org/protocol/muc#user");
            if (mucUser != null) {
                String j = mucUser.getItem().getJid();
                if (j != null && j.length() > 3)
                    getActionBar().setSubtitle(j);
            }
        }
    }

    LinearLayout linear = (LinearLayout) findViewById(R.id.linear);
    linear.setBackgroundColor(Colors.BACKGROUND);

    LayoutInflater inflater = LayoutInflater.from(this);
    View aboutPage = inflater.inflate(R.layout.vcard_about, null);
    View homePage = inflater.inflate(R.layout.vcard_home, null);
    View workPage = inflater.inflate(R.layout.vcard_work, null);
    View avatarPage = inflater.inflate(R.layout.vcard_avatar, null);
    View statusPage = inflater.inflate(R.layout.list_activity, null);

    first = (MyTextView) aboutPage.findViewById(R.id.firstname);
    middle = (MyTextView) aboutPage.findViewById(R.id.middlename);
    last = (MyTextView) aboutPage.findViewById(R.id.lastname);
    nick = (MyTextView) aboutPage.findViewById(R.id.nickname);
    bday = (MyTextView) aboutPage.findViewById(R.id.bday);
    url = (MyTextView) aboutPage.findViewById(R.id.url);
    about = (MyTextView) aboutPage.findViewById(R.id.desc);

    ctry = (MyTextView) homePage.findViewById(R.id.ctry);
    locality = (MyTextView) homePage.findViewById(R.id.locality);
    street = (MyTextView) homePage.findViewById(R.id.street);
    emailHome = (MyTextView) homePage.findViewById(R.id.homemail);
    phoneHome = (MyTextView) homePage.findViewById(R.id.homephone);

    org = (MyTextView) workPage.findViewById(R.id.org);
    unit = (MyTextView) workPage.findViewById(R.id.unit);
    role = (MyTextView) workPage.findViewById(R.id.role);
    emailWork = (MyTextView) workPage.findViewById(R.id.workmail);
    phoneWork = (MyTextView) workPage.findViewById(R.id.workphone);

    av = (ImageView) avatarPage.findViewById(R.id.av);
    av.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            File file = new File(Constants.PATH + jid.replaceAll("/", "%"));
            Uri uri = Uri.fromFile(file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(uri, "image/*");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException ignored) {
            }
        }
    });

    av.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            String fname = Constants.PATH + jid.replaceAll("/", "%");
            String saveto = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Avatars/";

            File folder = new File(saveto);
            folder.mkdirs();

            try {
                FileInputStream fis = new FileInputStream(fname);
                byte[] buffer = new byte[fis.available()];
                fis.read(buffer);
                fis.close();

                FileOutputStream fos = new FileOutputStream(saveto + "/" + jid.replaceAll("/", "%") + ".png");
                fos.write(buffer);
                fos.close();
                Toast.makeText(VCardActivity.this, "Copied to " + saveto, Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Toast.makeText(VCardActivity.this, "Failed to copy", Toast.LENGTH_LONG).show();
            }
            return true;
        }
    });

    statusProgress = (ProgressBar) statusPage.findViewById(R.id.progress);
    aboutProgress = (ProgressBar) aboutPage.findViewById(R.id.progress);
    homeProgress = (ProgressBar) homePage.findViewById(R.id.progress);
    workProgress = (ProgressBar) workPage.findViewById(R.id.progress);
    avatarProgress = (ProgressBar) avatarPage.findViewById(R.id.progress);

    aboutScroll = (ScrollView) aboutPage.findViewById(R.id.scroll);
    homeScroll = (ScrollView) homePage.findViewById(R.id.scroll);
    workScroll = (ScrollView) workPage.findViewById(R.id.scroll);
    avatarScroll = (ScrollView) avatarPage.findViewById(R.id.scroll);

    list = (ListView) statusPage.findViewById(R.id.list);
    list.setDividerHeight(0);
    list.setCacheColorHint(0x00000000);

    aboutPage.setTag(getString(R.string.About));
    homePage.setTag(getString(R.string.Home));
    workPage.setTag(getString(R.string.Work));
    avatarPage.setTag(getString(R.string.Photo));
    statusPage.setTag(getString(R.string.Status));

    ArrayList<View> mPages = new ArrayList<View>();
    mPages.add(aboutPage);
    mPages.add(homePage);
    mPages.add(workPage);
    mPages.add(avatarPage);
    mPages.add(statusPage);

    MainPageAdapter adapter = new MainPageAdapter(mPages);
    ViewPager mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(adapter);
    mPager.setCurrentItem(0);

    TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
    mTitleIndicator.setTextColor(0xFF555555);
    mTitleIndicator.setViewPager(mPager);
    mTitleIndicator.setCurrentItem(0);

    new LoadTask().execute();
}

From source file:bruce.kk.brucetodos.MainActivity.java

/**
 * ???/* w w  w.  j a  v a 2 s . com*/
 *
 * @param position
 */
private void modifyItem(final int position) {
    final UnFinishItem item = dataList.get(position);
    LogDetails.d(item);
    LinearLayout linearLayout = new LinearLayout(MainActivity.this);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(layoutParams);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setBackgroundColor(getResources().getColor(android.R.color.black));

    final EditText editText = new EditText(MainActivity.this);
    editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    editText.setTextColor(getResources().getColor(android.R.color.holo_green_light));
    editText.setHint(item.content);
    editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark));

    linearLayout.addView(editText);

    Button btnModify = new Button(MainActivity.this);
    btnModify.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    btnModify.setText("");
    btnModify.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    btnModify.setTextColor(getResources().getColor(android.R.color.holo_blue_bright));
    btnModify.setBackgroundColor(getResources().getColor(android.R.color.black));

    linearLayout.addView(btnModify);

    Button btnDeleteItem = new Button(MainActivity.this);
    btnDeleteItem.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    btnDeleteItem.setText("");
    btnDeleteItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    btnDeleteItem.setTextColor(getResources().getColor(android.R.color.holo_blue_bright));
    btnDeleteItem.setBackgroundColor(getResources().getColor(android.R.color.black));

    linearLayout.addView(btnDeleteItem);

    final PopupWindow popupWindow = new PopupWindow(linearLayout, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ?
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0);

    btnModify.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            LogDetails.d(": " + editText.getText().toString());
            if (!TextUtils.isEmpty(editText.getText().toString().trim())) {
                Date date = new Date();
                item.content = editText.getText().toString().trim();
                item.modifyDay = date;
                item.finishDay = null;
                ProgressDialogUtils.showProgressDialog();
                presenter.modifyItem(item);
                dataList.set(position, item);
                refreshData(true);
                popupWindow.dismiss();
            } else {
                Toast.makeText(MainActivity.this, "~", Toast.LENGTH_SHORT).show();
            }
        }
    });
    btnDeleteItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dataList.remove(position);
            presenter.deleteItem(item);
            refreshData(false);
            popupWindow.dismiss();
        }
    });
}

From source file:com.notepadlite.NoteListFragment.java

@Override
public void onResume() {
    super.onResume();

    // Before we do anything else, check for a saved draft; if one exists, load it
    SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE);
    if (getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) != 0) {
        Bundle bundle = new Bundle();
        bundle.putString("filename", "draft");

        Fragment fragment = new NoteEditFragment();
        fragment.setArguments(bundle);//from   ww  w . j  a v  a2s.c o  m

        // Add NoteEditFragment
        getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit();
    } else {
        if (getId() == R.id.noteViewEdit) {
            // Change window title
            String title = getResources().getString(R.string.app_name);

            getActivity().setTitle(title);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title,
                        null, getResources().getColor(R.color.primary));
                getActivity().setTaskDescription(taskDescription);
            }

            // Don't show the Up button in the action bar, and disable the button
            ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
            ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(false);
        }

        // Read preferences
        SharedPreferences pref = getActivity()
                .getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE);
        theme = pref.getString("theme", "light-sans");
        sortBy = pref.getString("sort_by", "date");
        showDate = pref.getBoolean("show_date", false);
        directEdit = pref.getBoolean("direct_edit", false);

        // Apply theme
        LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList);

        if (theme.contains("light")) {
            noteViewEdit.setBackgroundColor(getResources().getColor(R.color.window_background));
            noteList.setBackgroundColor(getResources().getColor(R.color.window_background));
        }

        if (theme.contains("dark")) {
            noteViewEdit.setBackgroundColor(getResources().getColor(R.color.window_background_dark));
            noteList.setBackgroundColor(getResources().getColor(R.color.window_background_dark));
        }

        // Refresh list of notes onResume (instead of onCreate) to reflect additions/deletions and preference changes
        listNotes();
    }
}

From source file:com.anjalimacwan.fragment.NoteListFragment.java

@Override
public void onResume() {
    super.onResume();

    // Before we do anything else, check for a saved draft; if one exists, load it
    SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE);
    if (getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) != 0) {
        Bundle bundle = new Bundle();
        bundle.putString("filename", "draft");

        Fragment fragment = new NoteEditFragment();
        fragment.setArguments(bundle);/*from   ww  w  .j a v  a2 s .c  om*/

        // Add NoteEditFragment
        getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit();
    } else {
        if (getId() == R.id.noteViewEdit) {
            // Change window title
            String title = getResources().getString(R.string.app_name);

            getActivity().setTitle(title);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title,
                        null, ContextCompat.getColor(getActivity(), R.color.primary));
                getActivity().setTaskDescription(taskDescription);
            }

            // Don't show the Up button in the action bar, and disable the button
            ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
            ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(false);
        }

        // Read preferences
        SharedPreferences pref = getActivity()
                .getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE);
        theme = pref.getString("theme", "light-sans");
        sortBy = pref.getString("sort_by", "date");
        showDate = pref.getBoolean("show_date", false);
        directEdit = pref.getBoolean("direct_edit", false);

        // Apply theme
        LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList);

        if (theme.contains("light")) {
            noteViewEdit.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
            noteList.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
        }

        if (theme.contains("dark")) {
            noteViewEdit
                    .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
            noteList.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
        }

        // Refresh list of notes onResume (instead of onCreate) to reflect additions/deletions and preference changes
        listNotes();
    }
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

public void setSelectRow(int paramInt) throws Exception {
    LinearLayout localLinearLayout1 = this.mLinerLock;
    Integer localInteger1 = Integer.valueOf(this.m_nPos);
    View localView1 = localLinearLayout1.findViewWithTag(localInteger1);
    if (localView1 != null) {
        int l = this.residCol;
        localView1.setBackgroundResource(l);
    }/*from  w ww .j a va 2 s .  c  o m*/
    LinearLayout localLinearLayout2 = this.mLinerLock;
    Integer localInteger2 = Integer.valueOf(paramInt);
    View localView2 = localLinearLayout2.findViewWithTag(localInteger2);
    if (localView2 != null) {
        int i1 = this.residSelColor;
        localView2.setBackgroundColor(i1);
    }

    if (true) {
        LinearLayout localLinerLock = this.mLinerLock2;
        Integer localLockInteger = Integer.valueOf(this.m_nPos);
        View localLockView = localLinerLock.findViewWithTag(localLockInteger);
        if (localLockView != null) {
            int l = this.residCol;
            localLockView.setBackgroundResource(l);
        }
        LinearLayout localLinerLock2 = this.mLinerLock2;
        Integer localLockInteger2 = Integer.valueOf(paramInt);
        View localLockView2 = localLinerLock2.findViewWithTag(localLockInteger2);
        if (localLockView2 != null) {
            int i1 = this.residSelColor;
            localLockView2.setBackgroundColor(i1);
        }
    }

    LinearLayout localLinearLayout3 = this.mLinerHScroll;
    Integer localInteger3 = Integer.valueOf(this.m_nPos);
    LinearLayout localLinearLayout4 = (LinearLayout) localLinearLayout3.findViewWithTag(localInteger3);

    if (localLinearLayout4 != null) {
        int i3 = localLinearLayout4.getChildCount();
        for (int i = 0; i < i3; i++) {
            View localView3 = localLinearLayout4.getChildAt(i);
            int i0 = 0;
            if (i == i3 - 1)
                i0 = this.residScrollCol[2];
            else if (i == 13)
                i0 = this.residScrollCol[1];
            else if (i % 2 == 0)
                i0 = this.residScrollCol[0];
            else
                i0 = this.residScrollCol[1];
            localView3.setBackgroundResource(i0);
        }
    }

    LinearLayout localLinearLayout5 = this.mLinerHScroll;
    Integer localInteger4 = Integer.valueOf(paramInt);
    LinearLayout localLinearLayout6 = (LinearLayout) localLinearLayout5.findViewWithTag(localInteger4);
    if (localLinearLayout6 != null) {
        int i4 = this.residSelColor;
        localLinearLayout6.setBackgroundColor(i4);
    }
    int i6 = localLinearLayout6.getChildCount();
    for (int i = 0; i < i6; i++) {
        View localView6 = localLinearLayout6.getChildAt(i);
        int i10 = this.residSelColor;
        localView6.setBackgroundColor(i10);
    }
    this.m_nPos = paramInt;

    if (null != stringList && stringList.size() > paramInt && null != temp2[m_nPos - 1]
            && !"".equals(temp2[m_nPos - 1]) && null != temp1[m_nPos - 1] && !"".equals(temp1[m_nPos - 1])
            && temp1[m_nPos - 1].length() > 2) {

        Log.i("tag", "stringList.length" + stringList.size() + " : paramInt : " + paramInt);

        String[] data = stringList.get(paramInt - 1);
        String market = data[data.length - 2];
        cssStock = new CssStock();
        cssStock.setStkcode(temp1[m_nPos - 1].substring(2)); // 
        cssStock.setStkname(temp2[m_nPos - 1]);
        cssStock.setMarket(market);
    }
    // this.cssStock = list.get(paramInt - 1);
}

From source file:it.iziozi.iziozi.gui.IOBoardFragment.java

private View buildView(boolean editMode) {

    this.homeRows.clear();
    final List<IOSpeakableImageButton> mButtons = new ArrayList<IOSpeakableImageButton>();
    List<IOSpeakableImageButton> configButtons = this.mBoard.getButtons();

    ViewGroup mainView = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.table_main_layout,
            null);/*w w w . j  av a 2s . c  o m*/

    LinearLayout tableContainer = new LinearLayout(getActivity());
    LinearLayout.LayoutParams mainParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    tableContainer.setLayoutParams(mainParams);
    tableContainer.setOrientation(LinearLayout.VERTICAL);

    for (int i = 0; i < this.mBoard.getRows(); i++) {

        LinearLayout rowLayout = new LinearLayout(getActivity());
        LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.f);
        rowLayout.setLayoutParams(rowParams);
        rowLayout.setOrientation(LinearLayout.HORIZONTAL);
        Random color = new Random();
        rowLayout.setBackgroundColor(Color.WHITE);
        tableContainer.addView(rowLayout);
        this.homeRows.add(rowLayout);
    }

    for (int j = 0; j < this.homeRows.size(); j++) {
        LinearLayout homeRow = this.homeRows.get(j);

        for (int i = 0; i < this.mBoard.getCols(); i++) {
            LinearLayout btnContainer = new LinearLayout(getActivity());
            LinearLayout.LayoutParams btnContainerParams = new LinearLayout.LayoutParams(0,
                    LinearLayout.LayoutParams.MATCH_PARENT, 1.f);
            btnContainer.setLayoutParams(btnContainerParams);
            btnContainer.setOrientation(LinearLayout.VERTICAL);
            btnContainer.setGravity(Gravity.CENTER);

            homeRow.addView(btnContainer);

            final IOSpeakableImageButton imgButton = (configButtons.size() > 0
                    && configButtons.size() > mButtons.size()) ? configButtons.get(mButtons.size())
                            : new IOSpeakableImageButton(getActivity());
            imgButton.setmContext(getActivity());
            imgButton.setShowBorder(IOConfiguration.getShowBorders());
            if (IOGlobalConfiguration.isEditing)
                imgButton.setImageDrawable(getResources().getDrawable(R.drawable.logo_org));
            else
                imgButton.setImageDrawable(null);
            imgButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            imgButton.setBackgroundColor(Color.TRANSPARENT);

            if (imgButton.getmImageFile() != null && imgButton.getmImageFile().length() > 0) {

                if (!new File(imgButton.getmImageFile()).exists()) {
                    if (mAlertDialog == null || !mAlertDialog.isShowing()) {
                        mAlertDialog = new AlertDialog.Builder(getActivity()).setCancelable(true)
                                .setTitle(getString(R.string.image_missing))
                                .setMessage(getString(R.string.image_missing_text))
                                .setNegativeButton(getString(R.string.continue_string), null).create();
                        mAlertDialog.show();
                    }

                    //download image

                    if (isExternalStorageReadable()) {

                        File baseFolder = new File(Environment.getExternalStorageDirectory() + "/"
                                + IOApplication.APPLICATION_FOLDER + "/pictograms");
                        Character pictoChar = imgButton.getmImageFile()
                                .charAt(imgButton.getmImageFile().lastIndexOf("/") + 1);
                        File pictoFolder = new File(baseFolder + "/" + pictoChar + "/");

                        if (isExternalStorageWritable()) {

                            pictoFolder.mkdirs();

                            //download it

                            AsyncHttpClient client = new AsyncHttpClient();
                            client.get(imgButton.getmUrl(),
                                    new FileAsyncHttpResponseHandler(new File(imgButton.getmImageFile())) {
                                        @Override
                                        public void onFailure(int statusCode, Header[] headers,
                                                Throwable throwable, File file) {
                                            Toast.makeText(getActivity(),
                                                    getString(R.string.download_error) + file.toString(),
                                                    Toast.LENGTH_LONG).show();
                                        }

                                        @Override
                                        public void onSuccess(int statusCode, Header[] headers,
                                                File downloadedFile) {

                                            if (new File(imgButton.getmImageFile()).exists()) {
                                                imgButton.setImageBitmap(
                                                        BitmapFactory.decodeFile(imgButton.getmImageFile()));
                                            } else {
                                                Toast.makeText(getActivity(),
                                                        getString(R.string.image_save_error),
                                                        Toast.LENGTH_SHORT).show();
                                            }
                                        }
                                    });
                        } else {

                            Toast.makeText(getActivity(), getString(R.string.image_save_error),
                                    Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_SHORT)
                                .show();
                    }

                } else
                    imgButton.setImageBitmap(BitmapFactory.decodeFile(imgButton.getmImageFile()));
            }

            ViewGroup parent = (ViewGroup) imgButton.getParent();

            if (parent != null)
                parent.removeAllViews();

            btnContainer.addView(imgButton);

            mButtons.add(imgButton);

            imgButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    int index = mButtons.indexOf(v);
                    if (mListener != null)
                        mListener.tapOnSpeakableButton(mButtons.get(index), mBoardLevel);
                }
            });
        }
    }

    this.mBoard.setButtons(mButtons.size() > configButtons.size() ? mButtons : configButtons);

    return tableContainer;
}

From source file:com.farmerbb.notepad.fragment.NoteListFragment.java

@Override
public void onResume() {
    super.onResume();

    // Before we do anything else, check for a saved draft; if one exists, load it
    SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE);
    if (getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) != 0) {
        Bundle bundle = new Bundle();
        bundle.putString("filename", "draft");

        Fragment fragment = new NoteEditFragment();
        fragment.setArguments(bundle);//from   ww  w.  j  a  va2s  .c  o  m

        // Add NoteEditFragment
        getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit();
    } else {
        if (getId() == R.id.noteViewEdit) {
            // Change window title
            String title = getResources().getString(R.string.app_name);

            getActivity().setTitle(title);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Bitmap bitmap = ((BitmapDrawable) ContextCompat.getDrawable(getActivity(),
                        R.drawable.ic_recents_logo)).getBitmap();

                ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title,
                        bitmap, ContextCompat.getColor(getActivity(), R.color.primary));
                getActivity().setTaskDescription(taskDescription);
            }

            // Don't show the Up button in the action bar, and disable the button
            ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
            ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(false);
        }

        // Read preferences
        SharedPreferences pref = getActivity()
                .getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE);
        theme = pref.getString("theme", "light-sans");
        sortBy = pref.getString("sort_by", "date");
        showDate = pref.getBoolean("show_date", false);
        directEdit = pref.getBoolean("direct_edit", false);

        // Apply theme
        LinearLayout noteViewEdit = getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = getActivity().findViewById(R.id.noteList);

        if (theme.contains("light")) {
            noteViewEdit.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
            noteList.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
        }

        if (theme.contains("dark")) {
            noteViewEdit
                    .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
            noteList.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
        }

        // Declare ListView
        listView = getActivity().findViewById(R.id.listView1);

        // Refresh list of notes onResume (instead of onCreate) to reflect additions/deletions and preference changes
        listNotes();
    }
}

From source file:com.joeyturczak.jtscanner.ui.ScannerFragment.java

@Override
public void onFocusChange(View v, boolean hasFocus) {
    EditText view = (EditText) v;//from  w  w  w . j a  v  a 2s .c o  m
    LinearLayout viewLayout = (LinearLayout) view.getParent();
    if (hasFocus) {
        viewLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary_blue_grey));
        view.setTextColor(ContextCompat.getColor(getContext(), R.color.accent));
        ViewCompat.setElevation(view, 8);
    } else {
        viewLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary_light_blue_grey));
        view.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black));
        ViewCompat.setElevation(view, 0);
    }
}

From source file:com.example.damerap_ver1.IntroVideoActivity.java

/**
* Create the view in which the video will be rendered.
*///from  w ww.j a  va 2 s  .com
private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
}