Example usage for android.view ViewGroup getContext

List of usage examples for android.view ViewGroup getContext

Introduction

In this page you can find the example usage for android.view ViewGroup getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.google.android.apps.santatracker.launch.TvStartupActivity.java

private void addDebugMenuListRaw(ArrayObjectAdapter objectAdapter) {

    mMarkers.setPadding(mMarkers.getPaddingLeft(), mMarkers.getPaddingTop() + 150, mMarkers.getPaddingRight(),
            mMarkers.getPaddingBottom());

    Presenter debugMenuPresenter = new Presenter() {
        @Override/*  w  w  w. j  a va2s.com*/
        public ViewHolder onCreateViewHolder(ViewGroup parent) {
            TextView tv = new TextView(parent.getContext());
            ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(200, 150);
            tv.setLayoutParams(params);
            tv.setGravity(Gravity.CENTER);
            tv.setBackgroundColor(getResources().getColor(R.color.SantaBlueDark));
            tv.setFocusableInTouchMode(false);
            tv.setFocusable(true);
            tv.setClickable(true);
            return new ViewHolder(tv);
        }

        @Override
        public void onBindViewHolder(ViewHolder viewHolder, Object item) {
            ((TextView) viewHolder.view).setText((String) item);
            viewHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final String text = ((TextView) v).getText().toString();
                    if (text.contains("Enable Tracker")) {
                        enableTrackerMode(true);
                    } else if (text.contains("Enable CountDown")) {
                        startCountdown(SantaPreferences.getCurrentTime());
                    } else {
                        mIsDebug = false;
                        initialiseViews();
                        resetLauncherStates();
                    }
                }
            });
        }

        @Override
        public void onUnbindViewHolder(ViewHolder viewHolder) {

        }
    };

    ObjectAdapter debugMenuAdapter = new ObjectAdapter(debugMenuPresenter) {

        private final String[] mMenuString = { "Enable Tracker", "Enable CountDown", "Hide DebugMenu" };

        @Override
        public int size() {
            return mMenuString.length;
        }

        @Override
        public Object get(int position) {
            return mMenuString[position];
        }
    };

    ListRow debugMenuListRow = new ListRow(debugMenuAdapter);
    objectAdapter.add(debugMenuListRow);
}

From source file:com.github.michalbednarski.intentslab.uihelpers.FragmentTabMergingPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int page) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }/*from   w ww .j  a  v a 2  s . c o  m*/

    // Get info about page
    final MultiFragmentPageInfo pageInfo = mPagesInfoMap[page];
    final int fragmentsOnPage = pageInfo != null ? pageInfo.fillInIds.length : 1;
    final int firstFragmentOnPage = mPageToFirstFragmentMap[page];

    // Prepare wrapper layout
    final View view;
    final Fragment[] addedFragments;
    if (pageInfo != null) {
        view = LayoutInflater.from(container.getContext()).inflate(pageInfo.containerLayout, container, false);
        container.addView(view);
        addedFragments = new Fragment[fragmentsOnPage];
    } else {
        view = null;
        addedFragments = null;
    }

    // Prepare all fragments on page
    final int pagerId = container.getId();
    for (int i = 0; i < fragmentsOnPage; i++) {
        final int fragmentIndex = firstFragmentOnPage + i;
        final int containerId = pageInfo == null ? pagerId : pageInfo.fillInIds[i];

        // Do we already have this fragment?
        String name = makeFragmentName(pagerId, fragmentIndex);
        Fragment fragment = mFragmentManager.findFragmentByTag(name);
        if (fragment != null) {
            if (DEBUG)
                Log.v(TAG, "Attaching item #" + fragmentIndex + ": f=" + fragment);
            if (fragment.getId() != containerId) {
                // Added to another container
                moveFragment(fragment, containerId);
            } else {
                // Already added, possibly detached
                if (pageInfo != null) {
                    // When activity was created this tab wasn't ready
                    // Detach and re-attach this fragment
                    mCurTransaction.detach(fragment);
                }

                mCurTransaction.attach(fragment);
            }
        } else {
            // Not added
            fragment = mFragments[fragmentIndex];

            if (DEBUG)
                Log.v(TAG, "Adding item #" + fragmentIndex + ": f=" + fragment);

            mCurTransaction.add(containerId, fragment, name);
        }

        // Deactivate menu if not on current page
        if (page != mCurrentPrimaryPage) {
            fragment.setMenuVisibility(false);
            fragment.setUserVisibleHint(false);
        }

        // For single fragment page return fragment
        if (pageInfo == null) {
            return fragment;
        }

        // On multi fragment page add to page
        addedFragments[i] = fragment;
    }

    // Return descriptor of multi fragment page
    return new AddedPageInfo(view, addedFragments);
}

From source file:com.jekyll.wu.widget.FreeSnackBar.java

private FreeSnackBar(ViewGroup parent) {
    mTargetParent = parent;//  w  ww  . j  a va2  s .  c o m
    mContext = parent.getContext();

    ThemeUtils.checkAppCompatTheme(mContext);

    LayoutInflater inflater = LayoutInflater.from(mContext);
    mView = (SnackbarLayout) inflater.inflate(R.layout.my_design_layout_snackbar, mTargetParent, false);

    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:com.ryan.ryanreader.fragments.CommentListingFragment.java

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

    super.onCreateView(inflater, container, savedInstanceState);
    final Context context = container.getContext();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    commentFontScale = PrefsUtility.appearance_fontscale_comments(context, prefs);

    headerItems = PrefsUtility.appearance_comment_header_items(context, prefs);

    final LinearLayout outer = new LinearLayout(context);
    outer.setOrientation(android.widget.LinearLayout.VERTICAL);

    loadingView = new LoadingView(context, context.getString(R.string.download_waiting), true, true);

    notifications = new LinearLayout(context);
    notifications.setOrientation(android.widget.LinearLayout.VERTICAL);

    lv = new ListView(context);

    lv.setSmoothScrollbarEnabled(false);
    lv.setVerticalFadingEdgeEnabled(false);

    final LinearLayout listHeader = createVerticalLinearLayout(context);
    this.listHeaderPost = createVerticalLinearLayout(context);
    this.listHeaderNotifications = createVerticalLinearLayout(context);
    this.listHeaderSelftext = createVerticalLinearLayout(context);

    listHeader.addView(listHeaderPost);/*from w  w  w .j  a va2 s  .  c om*/
    listHeader.addView(listHeaderNotifications);
    listHeader.addView(listHeaderSelftext);

    listFooter = createVerticalLinearLayout(context);

    lv.addHeaderView(listHeader);
    lv.addFooterView(listFooter, null, false);

    adapter = new CommentListingAdapter(context, this);
    lv.setAdapter(adapter);

    registerForContextMenu(lv);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (view instanceof RedditCommentView) {
                switch (PrefsUtility.pref_behaviour_actions_comment_tap(context, prefs)) {
                case COLLAPSE:
                    handleCommentVisibilityToggle((RedditCommentView) view);
                    break;
                case ACTION_MENU:
                    openContextMenu(view);
                    break;
                }
            } else if (position == 0 && post != null && !post.src.is_self) {
                LinkHandler.onLinkClicked(getSupportActivity(), post.url, false, post.src);
            }
        }
    });

    outer.addView(notifications);
    outer.addView(lv);

    final FrameLayout outerFrame = new FrameLayout(context);
    outerFrame.addView(outer);

    final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(context);

    final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(context,
            new BezelSwipeOverlay.BezelSwipeListener() {

                public boolean onSwipe(BezelSwipeOverlay.SwipeEdge edge) {

                    if (post == null)
                        return false;

                    toolbarOverlay.setContents(
                            post.generateToolbar(context, CommentListingFragment.this, toolbarOverlay));
                    toolbarOverlay.show(edge == BezelSwipeOverlay.SwipeEdge.LEFT
                            ? SideToolbarOverlay.SideToolbarPosition.LEFT
                            : SideToolbarOverlay.SideToolbarPosition.RIGHT);
                    return true;
                }

                public boolean onTap() {

                    if (toolbarOverlay.isShown()) {
                        toolbarOverlay.hide();
                        return true;
                    }

                    return false;
                }
            });

    outerFrame.addView(bezelOverlay);
    outerFrame.addView(toolbarOverlay);

    bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
    bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

    toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
    toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

    makeFirstRequest(context);

    return outerFrame;
}

From source file:com.mezcaldev.hotlikeme.ChatActivity.java

private void updateFireBaseRecyclerAdapter() {

    if (mFirebaseAdapter != null) {
        mFirebaseAdapter.cleanup();//  w  w  w  .  j av  a 2s. c  om
    }

    mFirebaseAdapter = new FirebaseRecyclerAdapter<ChatMessageModel, MessageViewHolder>(ChatMessageModel.class,
            R.layout.item_message_left, MessageViewHolder.class, recentMessages) {

        private static final int RIGHT_MSG = 0;
        private static final int LEFT_MSG = 1;

        @Override
        public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view;
            if (viewType == RIGHT_MSG) {
                view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right, parent,
                        false);
                return new MessageViewHolder(view);
            } else {
                view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_left, parent,
                        false);
                return new MessageViewHolder(view);
            }
        }

        @Override
        public int getItemViewType(int position) {
            ChatMessageModel model = getItem(position);

            if (model.getUserId().equals(mFirebaseUser.getUid())) {
                return RIGHT_MSG;
            } else {

                return LEFT_MSG;
            }
        }

        @Override
        protected void populateViewHolder(final MessageViewHolder viewHolder,
                final ChatMessageModel chatMessageModel, int position) {

            String messengerText = dateFormatter(chatMessageModel.getTimeStamp());

            //System.out.println("SIZE -------> " + positionMessages);

            int positionToLoadMessage;
            if (positionMessages - MESSAGE_LIMIT >= 0) {
                positionToLoadMessage = position + (positionMessages - MESSAGE_LIMIT);
            } else {
                positionToLoadMessage = position;
            }

            viewHolder.messageTextView.setText(decryptedMessages.get(positionToLoadMessage));
            viewHolder.messengerTextView.setText(messengerText);

            if (chatMessageModel.getPhotoUrl() == null) {
                viewHolder.messengerImageView.setImageDrawable(
                        ContextCompat.getDrawable(ChatActivity.this, R.drawable.ic_account_circle_black_24dp));
            } else {
                Glide.with(ChatActivity.this).load(chatMessageModel.getPhotoUrl())
                        .into(viewHolder.messengerImageView);
            }
        }
    };

    mMessageRecyclerView.setLayoutManager(mLinearLayoutManager);
    mMessageRecyclerView.setAdapter(mFirebaseAdapter);

    mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            super.onItemRangeInserted(positionStart, itemCount);

            int friendlyMessageCount = mFirebaseAdapter.getItemCount();
            int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition();

            // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll
            // to the bottom of the list to show the newly added message.
            if (lastVisiblePosition >= -1 || (positionStart >= (friendlyMessageCount - 1)
                    && lastVisiblePosition == (positionStart - 1))) {

                mLinearLayoutManager.setStackFromEnd(true);
                mLinearLayoutManager.scrollToPosition(positionStart);

                if (mFirebaseAdapter != null) {
                    mFirebaseAdapter.notifyDataSetChanged();
                }
            }
            Handler handlerSetAsRead = new Handler();
            Runnable runnableSetAsRead = new Runnable() {
                @Override
                public void run() {
                    if (isInFront && !mFirebaseAdapter.getItem(mFirebaseAdapter.getItemCount() - 1).getUserId()
                            .equals(mFirebaseUser.getUid())) {
                        //Log.i(TAG, "====> Item count: " + getItemCount() + " Item Position: " + position);
                        mFirebaseDatabaseReference.child(MESSAGES_RESUME).child("readIt").setValue(true);
                    }
                }
            };
            handlerSetAsRead.postDelayed(runnableSetAsRead, 2000);
        }
    });

    Handler reloadView = new Handler();
    reloadView.postDelayed(new Runnable() {
        @Override
        public void run() {
            mFirebaseAdapter.notifyDataSetChanged();
        }
    }, UPDATE_VIEW_DELAY);
}

From source file:com.tech.frontier.adapters.HeaderRecommendAdapter.java

@Override
public View getView(final int position, View view, ViewGroup container) {
    ViewHolder holder;/*from   ww  w.  j a va  2 s. co  m*/
    final Recommend item = getItem(position);
    if (view == null) {
        holder = new ViewHolder();
        view = LayoutInflater.from(context).inflate(R.layout.recommend_item, container, false);
        holder.imageView = (ImageView) view.findViewById(R.id.recommand_imageview);
        holder.titleTextView = (TextView) view.findViewById(R.id.recommend_title_tv);
        view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mItemClickListener != null) {
                    mItemClickListener.onClick(item);
                }
            }
        });
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    holder.titleTextView.setText(item.title);
    Picasso.with(container.getContext()).load(item.imgUrl).fit().into(holder.imageView);
    return view;
}

From source file:com.kowd.pcapp.client.android.fragment.ProductItemsFragment.java

@SuppressLint("InflateParams")
@Override/*  w w w  .j  a  v a 2 s.c  om*/
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle bundle) {
    super.onCreateView(inflater, container, bundle);

    final View localView = inflater.inflate(R.layout.pc_products_list, container, false);

    if (null != bundle) {
        mCategoryId = bundle.getInt(PCConstants.CATEGORY_ID_KEY, -1);
    }

    initLoader(mCategoryId);

    mGridView = (GridView) localView.findViewById(R.id.pc_products_list);

    final DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);

    final int pixelSize = getResources().getDimensionPixelSize(R.dimen.pc_thumb_size);
    final int widthScale = localDisplayMetrics.widthPixels / pixelSize;
    mColumnWidth = (localDisplayMetrics.widthPixels / widthScale);

    mAdapter = new ProductsGridViewAdapter(container.getContext(), mColumnWidth);
    mGridView.setColumnWidth(mColumnWidth);
    mGridView.setNumColumns(2);
    mGridView.setAdapter(mAdapter);

    mGridView.setOnItemClickListener(this);
    mGridView.setEmptyView(localView.findViewById(R.id.pc_products_progress_root));

    return localView;
}

From source file:com.nqsky.nest.home.activity.RecyclerGridFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final RecyclerListAdapter adapter = new RecyclerListAdapter(getActivity(), this) {
        View view;//from ww w.java  2 s  .  c o m

        @Override
        public ItemViewHolder onCreatViewFristVHoleder(ViewGroup parent, int viewType) {
            view = new WebView(getActivity());
            view.setId(R.id.webview);
            GridLayoutManager.LayoutParams params = new GridLayoutManager.LayoutParams(
                    GridLayoutManager.LayoutParams.MATCH_PARENT, 800);
            view.setLayoutParams(params);
            return new AppItemViewHolder(view, viewType);
        }

        @Override
        public ItemViewHolder onCreatViewItemVHoleder(ViewGroup parent, int viewType) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main, null, false);
            return new AppItemViewHolder(view, viewType);
        }

        @Override
        public ItemViewHolder onCreatViewHeaderVHoleder(ViewGroup parent, int viewType) {

            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header, parent, false);
            return new AppItemViewHolder(view, viewType);
        }

        @Override
        public void onBindViewFristHolder(ItemViewHolder holder, int position) {
            if (holder instanceof AppItemViewHolder) {
                ((AppItemViewHolder) holder).webview.loadUrl("http://www.qq.com");//.setText(super.mItems.get(position).getText());
            }

        }

        @Override
        public void onBindViewItemHolder(ItemViewHolder holder, int position) {
            if (holder instanceof AppItemViewHolder) {
                ((AppItemViewHolder) holder).textView.setText(super.mItems.get(position).getText());
                ((AppItemViewHolder) holder).handleView
                        .setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_app));

            }

        }

        @Override
        public void onBindViewHeaderHolder(ItemViewHolder holder, int position) {
            if (holder instanceof AppItemViewHolder) {
                ((AppItemViewHolder) holder).textView.setText(super.mItems.get(position).getText());
            }

        }
    };

    RecyclerView recyclerView = (RecyclerView) view.findViewById(android.R.id.list);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    //        final int spanCount = getResources().getInteger(R.integer.grid_columns);
    final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 4);
    recyclerView.setLayoutManager(layoutManager);

    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            switch (adapter.getItemViewType(position)) {
            case RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER:
                return 4;
            case RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER:
                return 4;
            case RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM:
                return 1;
            default:
                return 4;
            }
        }
    });

    ItemTouchHelper.Callback callback = new CJTouchHelperCallback(adapter);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(recyclerView);

    adapter.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(RecyclerGridFragment.this.getActivity(), "?" + position + "",
                    Toast.LENGTH_SHORT).show();
            if (adapter.getItemViewType(position) == RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM) {
                try {
                    ItemBean bean = new ItemBean();
                    bean.setText("?" + position + "");
                    bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM);
                    bean.setId(position / 10 + "");
                    bean.setpID(adapter.getItemBean(position).getpID());
                    adapter.addItem(adapter.getItemBean(position).getpID(), bean);
                } catch (NullPointerException e) {
                    e.printStackTrace();
                }

            } else {
                adapter.delItem(position + 1);

            }
        }
    });
    ItemBean bean;
    List<ItemBean> list = new ArrayList<ItemBean>();

    for (int i = 0; i < 80; i++) {
        bean = new ItemBean();
        if (i % 10 == 0) {
            bean.setText("" + i / 10);
            bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER);
            bean.setId(String.valueOf((i / 10)));
        } else {
            bean.setText("Item" + i / 10 + i % 10);
            bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM);
            bean.setpID(String.valueOf((i / 10)));
            bean.setId(String.valueOf((i)));
        }

        list.add(bean);
    }
    bean = new ItemBean();
    bean.setText("");
    bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER);
    bean.setId(String.valueOf((10)));
    list.add(0, bean);
    adapter.addItems(list);
    final com.cjj.MaterialRefreshLayout swipeRefreshLayout;
    final Handler handler = new Handler();

    swipeRefreshLayout = (com.cjj.MaterialRefreshLayout) view.findViewById(R.id.swipe_refresh_widget);
    swipeRefreshLayout.setWaveColor(0xf90fffff);
    swipeRefreshLayout.setIsOverLay(true);
    swipeRefreshLayout.setWaveShow(true);
    swipeRefreshLayout.setLoadMore(true);
    swipeRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() {

        @Override
        public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {

            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    adapter.clear();
                    ItemBean bean;
                    List<ItemBean> list = new ArrayList<ItemBean>();

                    for (int i = 0; i < 80; i++) {
                        bean = new ItemBean();
                        if (i % 10 == 0) {
                            bean.setText("" + i / 10);
                            bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER);
                            bean.setId(String.valueOf((i / 10)));
                        } else {
                            bean.setText("" + i / 10 + i % 10);
                            bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM);
                            bean.setpID(String.valueOf((i / 10)));
                            bean.setId(String.valueOf((i)));
                        }

                        list.add(bean);
                    }
                    bean = new ItemBean();
                    bean.setText("");
                    bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER);
                    bean.setId(String.valueOf((10)));
                    list.add(0, bean);
                    adapter.addItems(list);
                    materialRefreshLayout.finishRefresh();
                }
            }, 1000);

        }

        @Override
        public void onRefreshLoadMore(final MaterialRefreshLayout materialRefreshLayout) {
            super.onRefreshLoadMore(materialRefreshLayout);
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ArrayList list = new ArrayList<ItemBean>();

                    for (int i = 60; i < 90; i++) {
                        ItemBean bean = new ItemBean();
                        if (i % 10 == 0) {
                            bean.setText("" + i / 10);
                            bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER);
                            bean.setId(String.valueOf((i / 10)));
                        } else {
                            bean.setText("" + i / 10 + i % 10);
                            bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM);
                            bean.setpID(String.valueOf((i / 10)));
                            bean.setId(String.valueOf((i)));
                        }

                        list.add(bean);
                    }
                    //                        bean=new ItemBean();
                    //                        bean.setText("" );
                    //                        bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER);
                    //                        bean.setId(String.valueOf((10)));
                    //                        list.add(0,bean);
                    adapter.addItems(list);
                    materialRefreshLayout.finishRefreshLoadMore();
                }
            }, 1000);
        }
    });

}

From source file:de.gebatzens.ggvertretungsplan.fragment.NewsFragment.java

@Override
public void createView(LayoutInflater inflater, ViewGroup view) {
    lv = new ListView(getActivity());
    int p = toPixels(10);
    //lv.getDivider().setColorFilter(GGApp.GG_APP.provider.getColor(), PorterDuff.Mode.ADD);
    lv.setDrawSelectorOnTop(true);//from www  .java2 s . c  o m
    lv.setDivider(getResources().getDrawable(R.drawable.listview_divider));
    ((LinearLayout) view.findViewById(R.id.news_content)).addView(lv);
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            TextView txtTitle = (TextView) view.findViewById(R.id.newsTitle);
            TextView txtContent = (TextView) view.findViewById(R.id.newsContent);
            String mTitle = txtTitle.getText().toString();
            String mContent = txtContent.getText().toString();
            AlertDialog.Builder ad = new AlertDialog.Builder(view.getContext());
            ad.setTitle(mTitle);
            ad.setMessage(mContent);
            ad.setNegativeButton(GGApp.GG_APP.getResources().getString(R.string.close),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            ad.show();
            if (!mDatabaseHelper.checkNewsRead(mTitle)) {
                mDatabaseHelper.addReadNews(mTitle);
                nfla.notifyDataSetChanged();
            }
        }
    });
    nfla = new NewsFragmentListAdapter(getActivity(), GGApp.GG_APP.news);
    lv.setAdapter(nfla);
}

From source file:com.tmendes.birthdaydroid.AboutUsFragment.java

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

    View v = inflater.inflate(R.layout.fragment_about_us, container, false);

    TextView appVersion = (TextView) v.findViewById(R.id.tvVersion);
    TextView tvHelpDevel = (TextView) v.findViewById(R.id.tvHelpDevel);
    TextView tvHelpIssue = (TextView) v.findViewById(R.id.tvHelpIssue);
    TextView tvHelpTranslator = (TextView) v.findViewById(R.id.tvHelpTranslator);
    TextView tvIcons01 = (TextView) v.findViewById(R.id.tvIcons01);
    TextView tvTranslatorNames = (TextView) v.findViewById(R.id.tvTranslatorNames);

    tvHelpDevel.setMovementMethod(LinkMovementMethod.getInstance());
    tvHelpIssue.setMovementMethod(LinkMovementMethod.getInstance());
    tvHelpTranslator.setMovementMethod(LinkMovementMethod.getInstance());
    tvIcons01.setMovementMethod(LinkMovementMethod.getInstance());
    tvTranslatorNames.setMovementMethod(LinkMovementMethod.getInstance());

    appVersion/*from ww w. jav a2s . c o  m*/
            .setText(container.getContext().getResources().getString(R.string.build, BuildConfig.VERSION_CODE));

    return v;

}