2012-09-17 2 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

난 당신이 상자 솔루션의 아웃을 찾고 있습니다 생각합니다. 나는 최근에 똑같은 일을해야했고 상자 솔루션을 찾지 못했습니다. 내가 뭘 한거지? 알파 애니메이션으로 보이지 않는 뷰를 만들었고 사용자가 목록 뷰를 클릭하면 애니메이션이 시작되고 내용이 채워진 뷰가 표시됩니다.

사용자 정의 대화 상자를 만들고 xml 파일에서보기를 팽창시켜 다른 방법으로이 작업을 수행 할 수 있습니다.

설명보기와 상호 작용이 필요하지 않으면 수정 된보기로 토스트를 사용하고 사용자가 읽을 시간을 설정할 수 있습니다.

관련 문제