我只想将我的空活动数据传递给选项卡式活动 . 在我的代码中,我使用三个活动 . 一个是包含列表视图的主要活动 . 第二个是空活动...第三个是选项卡活动..在我的主要活动,用户可以从列表视图中单击项目...当用户单击项目时,项目传递给第二个活动..它完美地工作..现在我想将项目名称从MainActivity传递给TabbedActivity(DesAndCode - Activty Name)..这里我还包括我的代码..请查看它..

DesAndCode - TabbedActivity

package ajay.com.mydict;

import android.support.design.widget.TabLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import android.widget.TextView;
import android.widget.Toast;

public class DesAndCode extends AppCompatActivity {
    private SectionsPagerAdapter mSectionsPagerAdapter;
    private ViewPager mViewPager;
    static String s;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_des_and_code);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
         //get Intent value from ListActi.java 
         s = getIntent().getStringExtra("ClickedItem");   
        mViewPager = (ViewPager) findViewById(R.id.container);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(mViewPager);

    }


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

    @Override
    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();
   if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
    public static class PlaceholderFragment extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";
        public PlaceholderFragment() {
        }
        public static PlaceholderFragment newInstance(int sectionNumber) {
            PlaceholderFragment fragment = new PlaceholderFragment();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            fragment.setArguments(args);
            return fragment;
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // 1 -- > Description
            if(getArguments().getInt(ARG_SECTION_NUMBER)==1){
                View rootView = inflater.inflate(R.layout.fragment_code_page, container, false);
                TextView textView = (TextView) rootView.findViewById(R.id.code_page);
               //s has value which receives from ListActi 
                if(s.equals("Access Modifier")){
                    textView.setText(R.string.blackbox);
                }
                return rootView;
            }
            else { // Sample Code
                View rootView = inflater.inflate(R.layout.fragment_des_and_code, container, false);
                TextView textView = (TextView) rootView.findViewById(R.id.section_label);
                textView.setText(R.string.blackbox);
                return rootView;
            }
        }
    }
    public class SectionsPagerAdapter extends FragmentPagerAdapter {
        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }
        @Override
        public Fragment getItem(int position) {
            return PlaceholderFragment.newInstance(position + 1);
        }
        @Override
        public int getCount() {
            // Show 3 total pages.
            return 2;
        }
        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "DESCRIPTION";
                case 1:
                    return "SAMPLE CODE";
            }
            return null;
        }
    }
}

ListActi.java

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);
        lv = (ListView) findViewById(R.id.listView);
        final List<String> ListElementsArrayList = new ArrayList<String>(Arrays.asList(listElements));
        final ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (getApplicationContext(), android.R.layout.simple_list_item_1, ListElementsArrayList);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //Toast.makeText(getApplicationContext(), listElements[position],Toast.LENGTH_LONG).show();
                if(position == 1){
                    Intent i = new Intent(getApplicationContext(),DesAndCode.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 0){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 2){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 3){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 4){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 5){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 6){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 7){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }    if(position == 8){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 9){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 10){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
                if(position == 11){
                    Intent i = new Intent(getApplicationContext(),OnlyDes.class);
                    i.putExtra("ClickedItem", listElements[position]);
                    startActivity(i);
                }
            }
        });
    }
}