2012-09-17 30 views
2

我目前正在一个应用程序,但我需要帮助。我怎样才能把它放在你有清单的地方,当你按下一个项目时,它就会进入它的描述。一个例子可以在这个应用程序 https://play.google.com/store/apps/details?id=com.actionbarsherlock.sample.fragments&feature=more_from_developer#?t=W251bGwsMSwxLDEwMiwiY29tLmFjdGlvbmJhcnNoZXJsb2NrLnNhbXBsZS5mcmFnbWVudHMiXQ ..Android/Java如何将线性布局添加到片段?

我怎样才能得到你什么时候你按布局。

我有标签,但我无法获得列表。这是主要的活动代码。

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; 
    } 
} 

}

+0

不要一次帮助我。/s – idroid8

+0

我真的不明白你想要什么。你能用箭头或其他什么来画一个草图吗? –

回答

0

我认为你正在寻找一个开箱即用的解决方案。最近我不得不做同样的事情,我没有找到一个开箱即用的解决方案。我做了什么?我创建了一个带有alpha动画的不可见视图,当用户点击我的listview时,我开始动画并显示带有内容的填充视图。

还有其他方法可以通过创建自定义对话框并从xml文件中放大视图来实现此目的。

更简单的是,如果您不需要与描述视图进行交互,那么您可以使用带有修改视图的Toast并为用户设置时间来阅读。

相关问题