3
두 탭 중 FragmentActivity
을 만들었습니다. 내가 보여줄 필요가 2 탭 지금Android 다음 탭에 데이터를 표시하고 저장하십시오.
public static class Fragment01 extends Fragment {
private EditText mName;
private EditText mEmail1;
public static final String ARG_SECTION_NUMBER = "2";
public Fragment01() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_customer_add, container, false);
mName = (EditText) v.findViewById(R.id.customer_add_name);
mEmail = (EditText) v.findViewById(R.id.customer_add_email);
View confirmButton = v.findViewById(R.id.customer_add_button);
confirmButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
......................
}
});
}
}
이 2 tabs
에 내가 fragments
다른 2를 만든 다음 FragmentActivity
및 Code Here
public class FragmentPagerSupport extends FragmentActivity implements
ActionBar.TabListener {
SectionsPagerAdapter mSectionsPagerAdapter;
static final int NUM_ITEMS = 10;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_pager);
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
...........
}
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
Bundle args = new Bundle();
switch (position) {
case 0:
fragment = new Fragment01();
args.putInt(Fragment01.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
case 1:
fragment = new Fragment02();
args.putInt(Fragment02.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
return fragment;
}
}
FragmentPagerAdapter
를 사용하여 안드로이드 개발자 튜토리얼에서 아주 기본적인 Tab
예입니다 첫 번째 탭의 Name
및 Email
의 입력 값은 두 번째 탭의 확인시 database
에 저장해야합니다. 하지만 여기에 내가 붙어있다. first tab
의 데이터를 어떻게 보관할 수 있는지 알 수 없습니까? 도와주세요.
당신은 http://saigeethamn.blogspot.in/2009/10/shared-preferences-android-developer.html 이 링크 – Syn3sthete
이에서보세요 체크 매우 쉽게 값을 저장하는 SharedPreference를 사용할 수 있습니다 http://developer.android.com/training/basics/fragments/communicating.html – nedaRM