Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:arun.com.chromer.fragments.AboutFragment.java

private void populateData(View rootView) {
    ListView chromerList = (ListView) rootView.findViewById(R.id.about_app_version_list);
    ListView authorList = (ListView) rootView.findViewById(R.id.about_author_version_list);

    View daniel = rootView.findViewById(R.id.daniel);
    daniel.setOnClickListener(new View.OnClickListener() {
        @Override//ww w  .j  a  v  a  2 s. c o  m
        public void onClick(View v) {
            Intent googleIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://plus.google.com/u/0/+DanielCiao/about"));
            getActivity().startActivity(googleIntent);
        }
    });

    // Loading the header
    chromerList.setAdapter(new ExtendedBaseAdapter() {
        final Context context = getActivity().getApplicationContext();

        @Override
        public int getCount() {
            return 4;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater mInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false);
                holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image);
                holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle);
                holder.title = (TextView) convertView.findViewById(R.id.about_app_title);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            int materialdarkColor = ContextCompat.getColor(context, R.color.accent);
            holder.subtitle.setVisibility(View.VISIBLE);
            switch (position) {
            case 0:
                holder.title.setText(R.string.version);
                holder.subtitle.setText(Util.getPackageVersion(context));
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(GoogleMaterial.Icon.gmd_info_outline).color(materialdarkColor).sizeDp(24));
                break;
            case 1:
                holder.title.setText(R.string.changelog);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(GoogleMaterial.Icon.gmd_track_changes).color(materialdarkColor).sizeDp(24));
                break;
            case 2:
                holder.title.setText(R.string.join_google_plus);
                holder.subtitle.setText(R.string.share_ideas);
                holder.imageView.setBackground(
                        new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles_communities)
                                .color(materialdarkColor).sizeDp(24));
                break;
            case 3:
                holder.title.setText(R.string.licenses);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(GoogleMaterial.Icon.gmd_card_membership).color(materialdarkColor).sizeDp(24));
                break;
            }
            return convertView;
        }
    });

    authorList.setAdapter(new ExtendedBaseAdapter() {
        final Context context = getActivity().getApplicationContext();

        @Override
        public int getCount() {
            return 5;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater mInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false);
                holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image);
                holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle);
                holder.title = (TextView) convertView.findViewById(R.id.about_app_title);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            switch (position) {
            case 0:
                holder.title.setText(StringConstants.ME);
                holder.subtitle.setText(StringConstants.LOCATION);
                holder.imageView.getLayoutParams().height = (int) getResources()
                        .getDimension(R.dimen.arun_height);
                holder.imageView.getLayoutParams().width = (int) getResources()
                        .getDimension(R.dimen.arun_width);
                Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arun);
                RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory
                        .create(getResources(), imageBitmap);
                roundedBitmapDrawable.setAntiAlias(true);
                roundedBitmapDrawable.setCircular(true);
                holder.imageView.setImageDrawable(roundedBitmapDrawable);
                break;
            case 1:
                holder.title.setText(R.string.add_to_circles);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(
                        new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles)
                                .color(ContextCompat.getColor(getActivity(), R.color.google_plus)).sizeDp(24));
                break;
            case 2:
                holder.title.setText(R.string.follow_twitter);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView
                        .setBackground(new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_twitter)
                                .color(ContextCompat.getColor(getActivity(), R.color.twitter)).sizeDp(24));
                break;
            case 3:
                holder.title.setText(R.string.connect_linkedIn);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(
                        new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_linkedin_box)
                                .color(ContextCompat.getColor(getActivity(), R.color.linkedin)).sizeDp(24));
                break;
            case 4:
                holder.title.setText(R.string.more_apps);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(CommunityMaterial.Icon.cmd_google_play)
                        .color(ContextCompat.getColor(getActivity(), R.color.playstore_green)).sizeDp(24));
                break;
            }
            return convertView;
        }
    });

    chromerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                return;
            case 1:
                ChangelogUtil.showChangelogDialog(getActivity());
                break;
            case 2:
                Intent googleIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https://plus.google.com/communities/109754631011301174504"));
                getActivity().startActivity(googleIntent);
                break;
            case 3:
                new LicensesDialog.Builder(getActivity()).setNotices(Licenses.getNotices())
                        .setTitle(R.string.licenses).build().showAppCompat();
                break;
            }
        }
    });

    authorList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                return;
            case 1:
                Intent googleIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://google.com/+arunkumar5592"));
                getActivity().startActivity(googleIntent);
                break;
            case 2:
                Intent twitterIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https://twitter.com/arunkumar_9t2"));
                getActivity().startActivity(twitterIntent);
                break;
            case 3:
                Intent linkedinIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://in.linkedin.com/in/arunkumar9t2"));
                getActivity().startActivity(linkedinIntent);
                break;
            case 4:
                try {
                    getActivity().startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Arunkumar")));
                } catch (android.content.ActivityNotFoundException anfe) {
                    getActivity().startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/search?q=pub:Arunkumar")));
                }
                break;
            }
        }
    });

}

From source file:com.partypoker.poker.engagement.reach.activity.EngagementPollActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    /* Init layout */
    super.onCreate(savedInstanceState);

    /* If no content, nothing to do, super class already called finish */
    if (mContent == null)
        return;// ww w  .ja v  a  2 s  . c  o  m

    /* Render questions */
    LinearLayout questionsLayout = getView("questions");
    JSONArray questions = mContent.getQuestions();
    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    try {
        for (int i = 0; i < questions.length(); i++) {
            /* Get question */
            JSONObject question = questions.getJSONObject(i);

            /* Inflate question layout */
            LinearLayout questionLayout = (LinearLayout) layoutInflater
                    .inflate(getLayoutId("engagement_poll_question"), null);

            /* Set question's title */
            TextView questionTitle = (TextView) questionLayout.findViewById(getId("question_title"));
            questionTitle.setText(question.getString("title"));

            /* Set choices */
            RadioGroup choicesView = (RadioGroup) questionLayout.findViewById(getId("choices"));
            choicesView.setTag(question);
            JSONArray choices = question.getJSONArray("choices");
            int choiceViewId = 0;
            for (int j = 0; j < choices.length(); j++) {
                /* Get choice */
                JSONObject choice = choices.getJSONObject(j);

                /* Inflate choice layout */
                RadioButton choiceView = (RadioButton) layoutInflater
                        .inflate(getLayoutId("engagement_poll_choice"), null);

                /* Each choice is a radio button */
                choiceView.setId(choiceViewId++);
                choiceView.setTag(choice.getString("id"));
                choiceView.setText(choice.getString("title"));
                choiceView.setChecked(choice.optBoolean("isDefault"));
                choicesView.addView(choiceView);
            }

            /* Add to parent layouts */
            questionsLayout.addView(questionLayout);

            /* Watch state */
            mRadioGroups.add(choicesView);
            choicesView.setOnCheckedChangeListener(mRadioGroupListener);
        }
    } catch (JSONException jsone) {
        /* Drop on parsing error */
        mContent.dropContent(this);
        finish();
        return;
    }

    /* Disable action if a choice is not selected */
    updateActionState();
}

From source file:com.example.oris1991.anotherme.ExternalCalendar.CalendarAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;//from   w  w w  . j av a 2 s .c om
    TextView dayView;
    if (convertView == null) { // if it's not recycled, initialize some
        // attributes
        LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.calendar_item, null);

    }
    dayView = (TextView) v.findViewById(R.id.date);
    // separates daystring into parts.
    String[] separatedTime = dayString.get(position).split("-");
    // taking last part of date. ie; 2 from 2012-12-02
    String gridvalue = separatedTime[2].replaceFirst("^0*", "");
    // checking whether the day is in current month or not.
    if ((Integer.parseInt(gridvalue) > 1) && (position < firstDay)) {
        // setting offdays to white color.
        dayView.setTextColor(ContextCompat.getColor(mContext, R.color.summer));
        dayView.setClickable(false);
        dayView.setFocusable(false);
    } else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
        dayView.setTextColor(ContextCompat.getColor(mContext, R.color.summer));
        dayView.setClickable(false);
        dayView.setFocusable(false);
    } else {
        // setting curent month's days in blue color.
        dayView.setTextColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
    }

    if (dayString.get(position).equals(curentDateString)) {
        setSelected(v);
        previousView = v;
    } else {
        v.setBackgroundResource(R.drawable.list_item_background);
    }
    dayView.setText(gridvalue);

    // create date string for comparison
    String date = dayString.get(position);

    if (date.length() == 1) {
        date = "0" + date;
    }
    String monthStr = "" + (month.get(GregorianCalendar.MONTH) + 1);
    if (monthStr.length() == 1) {
        monthStr = "0" + monthStr;
    }

    // show icon if date is not empty and it exists in the items array
    ImageView iw = (ImageView) v.findViewById(R.id.date_icon);
    if (date.length() > 0 && items != null && items.contains(date)) {
        iw.setVisibility(View.VISIBLE);
    } else {
        iw.setVisibility(View.INVISIBLE);
    }
    return v;
}

From source file:com.inde.shiningdays.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //umeng sdk/*w w  w . ja  v  a  2  s.c o m*/
    MobclickAgent.updateOnlineConfig(this);

    mTitle = mDrawerTitle = getTitle();
    initViews();

    //start update widget service
    startUpdateWidgetService();

    // set a custom shadow that overlays the main content when the drawer opens
    //mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.type_list_footer, null, false);
    mEditType = footerView.findViewById(R.id.edit_type);
    //edit type button click
    mEditType.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), TypeActivity.class);
            startActivity(intent);
            finish();
        }

    });
    mDrawerList.addFooterView(footerView);
    mDrawerList.setAdapter(getSimpleAdapter());
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer_used, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    //enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    if (savedInstanceState == null) {
        selectItem(0, this.getCurrentSortRule());
    }
    //init drawer list
    initDrawerList();
    //show rate dialog
    showRateDialog();
}

From source file:at.alladin.rmbt.android.fragments.result.RMBTResultPagerFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);// w w w .  j  a  va  2 s.  co m

    final Bundle args = getArguments();

    final String uuid = args.getString(ARG_TEST_UUID);
    System.out.println("ResultPagerFragment: test uuid: " + uuid);

    pagerAdapter = new RMBTResultPagerAdapter((RMBTMainActivity) getActivity(), handler, uuid);
    pagerAdapter.setOnCompleteListener(new OnCompleteListener() {

        @Override
        public void onComplete(int flag, Object object) {
            if (pagerAdapter.getCount() > tabHost.getTabWidget().getChildCount()) {
                if (getActivity() != null) {
                    LayoutInflater inflater = (LayoutInflater) getActivity()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                    for (int i = tabHost.getTabWidget().getChildCount(); i < pagerAdapter.getCount(); i++) {
                        TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
                        //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
                        tab.setContent(android.R.id.tabcontent);

                        View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
                        TextView title = (TextView) indicator.findViewById(android.R.id.title);
                        title.setText(getActivity().getResources().getStringArray(
                                R.array.result_page_title)[RMBTResultPagerAdapter.RESULT_PAGE_TAB_TITLE_MAP
                                        .get(i)]);

                        tab.setIndicator(indicator);

                        tabHost.addTab(tab);
                    }
                }
            }
        }
    });

    if (MAP_INDICATOR_DYNAMIC_VISIBILITY) {
        pagerAdapter.setOnDataChangedListener(new OnDataChangedListener() {

            @Override
            public void onChange(Object oldValue, Object newValue, Object flag) {
                if (flag.equals("HAS_MAP")) {
                    boolean b = (Boolean) newValue;
                    if (b) {
                        tabHost.getTabWidget().getChildTabViewAt(RMBTResultPagerAdapter.RESULT_PAGE_MAP)
                                .setVisibility(View.VISIBLE);
                    } else {
                        tabHost.getTabWidget().getChildTabViewAt(RMBTResultPagerAdapter.RESULT_PAGE_MAP)
                                .setVisibility(View.GONE);
                    }
                }
            }
        });
    }
}

From source file:com.money.manager.ex.adapter.CategoryExpandableListAdapter.java

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {/*  ww w  . j ava2 s. c o m*/
    CategoryListItemViewHolderChild holder;
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(mLayout, null);

        holder = new CategoryListItemViewHolderChild(convertView);

        convertView.setTag(holder);
    } else {
        holder = (CategoryListItemViewHolderChild) convertView.getTag();
    }

    QueryCategorySubCategory entity = (QueryCategorySubCategory) getChild(groupPosition, childPosition);
    if (entity == null)
        return convertView;

    holder.text1.setText(entity.getSubcategoryName());

    holder.text2.setText(entity.getCategName());
    holder.text2.setTextColor(getContext().getResources().getColor(android.R.color.darker_gray));

    // Selector. Always hidden on subcategories.

    //      if (mShowSelector) {
    //         holder.selector.setVisibility(View.VISIBLE);
    //         // set the tag to be the group position
    //         holder.selector.setTag(entity.getCategId() + ":" + entity.getSubCategId());
    //
    //         holder.selector.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //               String tag = v.getTag().toString();
    //               String[] ids = tag.split(":");
    //               Integer groupId = Integer.parseInt(ids[0]);
    //               Integer childId = Integer.parseInt(ids[1]);
    //               setIdChildChecked(groupId, childId);
    //               // close
    //               closeFragment();
    //            }
    //         });
    //      } else {
    holder.selector.setVisibility(View.GONE);
    //      }

    // indent subcategory
    holder.indent.setVisibility(View.VISIBLE);

    return convertView;
}

From source file:com.gigigo.imagerecognition.vuforia.VuforiaActivity.java

@Override
public void setContentViewTop(View vuforiaView) {

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.ir_activity_vuforia, null);
    scanLine = view.findViewById(R.id.scan_line);
    RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.layoutContentVuforiaGL);
    relativeLayout.addView(vuforiaView, 0);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)

        markFakeFeaturePoint = new MarkFakeFeaturePoint(this);
    relativeLayout.addView(markFakeFeaturePoint);
    ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);

    addContentView(view, vlp);/*from w  w w  .j a v  a 2  s.  c  om*/

    //region Button Close
    view.findViewById(R.id.btnCloseVuforia).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent i = new Intent();
            i.putExtra(ImageRecognitionConstants.VUFORIA_PATTERN_ID, "");
            setResult(Activity.RESULT_CANCELED, i);
            finish();

        }
    });
    //endregion
    mVuforiaView = vuforiaView;
    setThemeColorScheme();

    startBoringAnimation();
    scanlineStart();

}

From source file:com.irccloud.android.fragment.NamesListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();/*w  w  w . j  a v a  2  s .  c  om*/
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText("No results found.");
    if (savedInstanceState != null && savedInstanceState.containsKey("event")) {
        event = new IRCCloudJSONObject(savedInstanceState.getString("event"));
        users = event.getJsonNode("members");
        adapter = new UsersAdapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    Dialog d = new AlertDialog.Builder(ctx).setTitle("NAMES response for " + event.getString("chan")).setView(v)
            .setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    return d;
}

From source file:com.comrella.webcomics.navigation.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Status bar/*from w ww  . ja  v  a2  s  . c  om*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(getResources().getColor(R.color.darkpink));
    }

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    //Custom tab viewer
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.custom_ab, null);
    tabBarView = (TabBarView) v.findViewById(R.id.tab_bar);

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setCustomView(v);

    // Set up the action bar.

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(pageChangeListener);

    tabBarView.setViewPager(mViewPager);

}

From source file:com.jwork.dhammapada.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    log.v(this, "onCreate()");
    if (CrashHandler.getInstance().isCrashFlag()) {
        log.v(this, "Crash flag detected");
        showCrashDialog();/*from www.  j  a  v a 2s  .  c om*/
    } else {
        //         setTheme(MainActivity.THEME);
        //         requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        mainLayout = (FrameLayout) findViewById(R.id.mainLayout);
        mainLayout.getForeground().setAlpha(0);

        LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        aboutWindow = new PopupWindow(inflater.inflate(R.layout.activity_about, null, false),
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
        TextView text = ((TextView) aboutWindow.getContentView().findViewById(R.id.about_text));
        text.setText(Html.fromHtml(
                getString(R.string.about_html).replaceAll("\\{0\\}", CrashHandler.getVersionName(this))
                        .replaceAll("\\{1\\}", "" + CrashHandler.getVersionCode(this))));
        text.setMovementMethod(LinkMovementMethod.getInstance());
        ImageButton button = ((ImageButton) aboutWindow.getContentView().findViewById(R.id.about_ok));
        button.setOnClickListener(this);

        controller = new DhammapadaController(this, viewHandler);

        Message message = Message.obtain();
        message.what = Constant.WHAT_DISPLAY_CHAPTER;
        controller.executeMessage(message);

        message = Message.obtain();
        message.what = Constant.WHAT_INIT;
        controller.executeMessage(message);

        //         ActionBar actionBar = getSupportActionBar();
        //         actionBar.hide();
        //         actionBar.setTitle("Dhammapada");
        //         actionBar.setSubtitle("Chapter");
        //         actionBar.setLogo(R.drawable.ic_launcher);
        //         actionBar.show();
    }
}