Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android/Java如何向片段添加线性布局?_Java_Android_Android Layout_Android 4.0 Ice Cream Sandwich - Fatal编程技术网

Android/Java如何向片段添加线性布局?

Android/Java如何向片段添加线性布局?,java,android,android-layout,android-4.0-ice-cream-sandwich,Java,Android,Android Layout,Android 4.0 Ice Cream Sandwich,我目前正在开发一个应用程序,但我需要帮助。如果你有一个列表,当你按下一个项目时,它会进入它的描述,我怎么能把它放在那里呢。可以在此应用程序上找到一个示例 .. 当你按布局时,我怎么能得到你得到的 我有标签,但我不能得到清单。这是主要的活动代码 public class MainActivity extends FragmentActivity implements ActionBar.TabListener { /** * The {@link android.support.v4.vie

我目前正在开发一个应用程序,但我需要帮助。如果你有一个列表,当你按下一个项目时,它会进入它的描述,我怎么能把它放在那里呢。可以在此应用程序上找到一个示例 ..

当你按布局时,我怎么能得到你得到的

我有标签,但我不能得到清单。这是主要的活动代码

public class MainActivity extends FragmentActivity implements ActionBar.TabListener {

/**
 * The {@link android.support.v4.view.PagerAdapter} that will provide fragments for each of the
 * sections. We use a {@link android.support.v4.app.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 android.support.v4.app.FragmentStatePagerAdapter}.
 */
SectionsPagerAdapter mSectionsPagerAdapter;

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding tab.
    // We can also use ActionBar.Tab#select() to do this if we have a reference to the
    // Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}



@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // When the given tab is selected, switch to the corresponding page in the ViewPager.
    mViewPager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

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

    public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        Fragment fragment = new DummySectionFragment();
        Bundle args = new Bundle();
        args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
        fragment.setArguments(args);
        return fragment;
    }

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

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0: return getString(R.string.title_section1).toUpperCase();
            case 1: return getString(R.string.title_section2).toUpperCase();
            case 2: return getString(R.string.title_section3).toUpperCase();
            case 3: return getString(R.string.title_section4).toUpperCase();
        }
        return null;
    }
}

/**
 * A dummy fragment representing a section of the app, but that simply displays dummy text.
 */
public static class DummySectionFragment extends Fragment {
    public DummySectionFragment() {
    }

    public static final String ARG_SECTION_NUMBER = "section_number";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        TextView textView = new TextView(getActivity());
        textView.setGravity(Gravity.CENTER);
        Bundle args = getArguments();
        textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
        return textView;
    }
}
public类MainActivity扩展FragmentActivity实现ActionBar.TabListener{
/**
*{@link android.support.v4.view.PagerAdapter},它将为每个
*我们使用{@link android.support.v4.app.FragmentPagerAdapter}派生,它将
*将每个加载的片段都保存在内存中。如果这变得太占用内存,可能是最好的
*切换到{@link android.support.v4.app.FragmentStatePagerAdapter}。
*/
分段SPAGERADAPTER mSectionsPagerAdapter;
/**
*将承载节内容的{@link ViewPager}。
*/
ViewPager mViewPager;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//创建适配器,该适配器将为三个主要部分中的每个部分返回一个片段
//应用程序的名称。
mSectionsPagerAdapter=newsectionspageradapter(getSupportFragmentManager());
//设置操作栏。
最终ActionBar ActionBar=getActionBar();
actionBar.setNavigationMode(actionBar.NAVIGATION\u MODE\u选项卡);
//使用分区适配器设置ViewPager。
mViewPager=(ViewPager)findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
//在不同区段之间滑动时,选择相应的选项卡。
//如果有对
//标签。
mViewPager.setOnPageChangeListener(新的ViewPager.SimpleOnPageChangeListener(){
@凌驾
已选择页面上的公共无效(内部位置){
actionBar.setSelectedNavigationItem(位置);
}
});
//对于应用程序中的每个部分,在操作栏中添加一个选项卡。
对于(int i=0;i

}我认为您正在寻找现成的解决方案。最近我不得不做同样的事情,但我没有找到现成的解决方案。我做了什么?我创建了一个带有alpha动画的不可见视图,当用户单击我的listview时,我启动动画并显示包含内容的填充视图

还有其他方法可以通过创建自定义对话框和从xml文件扩展视图来实现这一点


如果您不需要与description视图交互,那么就可以使用带有修改视图的Toast,并为用户设置阅读时间。

我认为您正在寻找现成的解决方案。最近我不得不做同样的事情,但我没有找到现成的解决方案。我做了什么?我创建了一个带有alpha动画的不可见视图,当用户单击我的listview时,我启动动画并显示包含内容的填充视图

还有其他方法可以通过创建自定义对话框和从xml文件扩展视图来实现这一点

更简单的是,如果您不需要与description视图交互,那么您可以为我们提供帮助