Click here to Skip to main content
15,041,025 members
Home / Discussions / Android


QuestionHow to send the added total marks to multiple activities in android Pin
Member 1309533820-Jul-17 23:48
MemberMember 1309533820-Jul-17 23:48 
SuggestionRe: How to send the added total marks to multiple activities in android Pin
David Crow21-Jul-17 10:35
MemberDavid Crow21-Jul-17 10:35 
Questiongif emoji Pin
Simran Sharma15-Jul-17 23:53
MemberSimran Sharma15-Jul-17 23:53 
AnswerRe: gif emoji Pin
Richard MacCutchan16-Jul-17 1:32
mveRichard MacCutchan16-Jul-17 1:32 
Questionchat Pin
Simran Sharma16-Jul-17 0:48
MemberSimran Sharma16-Jul-17 0:48 
AnswerRe: chat Pin
Richard MacCutchan16-Jul-17 1:32
mveRichard MacCutchan16-Jul-17 1:32 
AnswerRe: chat Pin
David Crow17-Jul-17 10:27
MemberDavid Crow17-Jul-17 10:27 
Questionmake book reader with feature of search and go to page Pin
Ali_Abdelrhim10-Jul-17 2:08
MemberAli_Abdelrhim10-Jul-17 2:08 

I am new to Android, and I am making a book reader (not for all books) but only for one textbook. I started with the demo for multi-pages in Android developers section and I added some text to it. My question is, is that the correct example I used (TextView)? here is my code:
I ma saving the strings in "String.xml" file.

public class MainActivity extends AppCompatActivity {

     * The {@link} that will provide
     * fragments for each of the sections. We use a
     * {@link FragmentPagerAdapter} derivative, which will keep every
     * loaded fragment in memory. If this becomes too memory intensive, it
     * may be best to switch to a
     * {@link}.
    private SectionsPagerAdapter mSectionsPagerAdapter;

     * The {@link ViewPager} that will host the section contents.
    private ViewPager mViewPager;

    protected void onCreate(Bundle savedInstanceState) {

        Toolbar toolbar = (Toolbar) findViewById(;
        // Create the adapter that will return a fragment for each of the three
        // primary sections of the activity.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(;

     /* FloatingActionButton fab = (FloatingActionButton) findViewById(;
      fab.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
              Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                      .setAction("Action", null).show();


    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == {
            PlaceholderFragment p = PlaceholderFragment.newInstance(1);

            return true;

        return super.onOptionsItemSelected(item);

     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
     * one of the sections/tabs/pages.
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {

        public Fragment getItem(int position) {
            // getItem is called to instantiate the fragment for the given page.
            // Return a PlaceholderFragment (defined as a static inner class below).
            return PlaceholderFragment.newInstance(position + 1);

        public int getCount() {
            // Show 600 total pages.
            return 604;

        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "SECTION 1";
                case 1:
                    return "SECTION 2";
                case 2:
                    return "SECTION 3";
            return null;

     * A placeholder fragment containing a simple view.
    public static class PlaceholderFragment extends Fragment  {
         * The fragment argument representing the section number for this
         * fragment.
        private static final String ARG_SECTION_NUMBER = "section_number";

        private static final String ARG_PAGE_NUMBER = "page_number";

         * Returns a new instance of this fragment for the given section
         * number.
        public static PlaceholderFragment newInstance(int sectionNumber) {
            PlaceholderFragment fragment = new PlaceholderFragment();

            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            return fragment;

        public PlaceholderFragment() {

        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            TextView textView = (TextView) rootView.findViewById(;
           // textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
            //String page = "page"+getArguments().getInt(ARG_SECTION_NUMBER);
            //textView.setText(getString("R.string." + page));
            int page_number_to_go =1;
            page_number_to_go = getArguments().getInt(ARG_SECTION_NUMBER);
            goToPage(textView, page_number_to_go);
           // Toolbar toolbar = (Toolbar) rootView.findViewById(;
           // getSupportActionBar(toolbar);

            return rootView;
        public void goToPage(TextView textView, int page_number){
            switch (page_number){
                case 1:
                    // toolbar.setTitle("صفحة رقم 1");
                case 2:
                    // toolbar.setTitle("صفحة رقم 2");
                case 3:
                    // toolbar.setTitle("صفحة رقم 3");
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                case 11:
                case 12:

QuestionRe: make book reader with feature of search and go to page Pin
David Crow11-Jul-17 13:36
MemberDavid Crow11-Jul-17 13:36 
AnswerRe: make book reader with feature of search and go to page Pin
Ali_Abdelrhim13-Jul-17 2:45
MemberAli_Abdelrhim13-Jul-17 2:45 
GeneralRe: make book reader with feature of search and go to page Pin
David Crow13-Jul-17 2:57
MemberDavid Crow13-Jul-17 2:57 
Suggestionsystem ui failed Pin
Member 131159839-Jul-17 23:50
MemberMember 131159839-Jul-17 23:50 
Questioncoding Pin
Member 132908393-Jul-17 21:01
MemberMember 132908393-Jul-17 21:01 
AnswerRe: coding Pin
Richard MacCutchan3-Jul-17 21:26
mveRichard MacCutchan3-Jul-17 21:26 
Questionandroid studio Pin
Member 132908393-Jul-17 20:36
MemberMember 132908393-Jul-17 20:36 
AnswerRe: android studio Pin
Richard MacCutchan3-Jul-17 21:25
mveRichard MacCutchan3-Jul-17 21:25 
SuggestionRe: android studio Pin
David Crow5-Jul-17 4:48
MemberDavid Crow5-Jul-17 4:48 
QuestionHow do I issue a command that chooses what activity to show in android app? Pin
Gemson Gonzales27-Jun-17 21:24
MemberGemson Gonzales27-Jun-17 21:24 
AnswerRe: How do I issue a command that chooses what activity to show in android app? Pin
Richard MacCutchan28-Jun-17 8:48
mveRichard MacCutchan28-Jun-17 8:48 
QuestionColor detection in android Pin
Member 1085025318-Jun-17 9:46
MemberMember 1085025318-Jun-17 9:46 
AnswerRe: Color detection in android Pin
Ravi Bhavnani18-Jun-17 11:25
professionalRavi Bhavnani18-Jun-17 11:25 
AnswerRe: Color detection in android Pin
Richard MacCutchan18-Jun-17 23:02
mveRichard MacCutchan18-Jun-17 23:02 
AnswerMessage Closed Pin
11-Aug-17 2:30
MemberAbdhulrahuman11-Aug-17 2:30 
Questionsource code to make online appointment app Pin
Member 1325839413-Jun-17 20:39
MemberMember 1325839413-Jun-17 20:39 
AnswerRe: source code to make online appointment app Pin
Richard MacCutchan13-Jun-17 21:47
mveRichard MacCutchan13-Jun-17 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.