Salve, ho un problema con la visualizzazione di dati da Database in tabbed Activity.
Se visualizzo i dati in una Activity funziona tutto.
Se invece devo visualizzare i dati in una tab non visualizza nulla.
UserActivity.java
le 3 tab hanno questo codice (rispettivamente 1 / 2 / 3)codice:public class UserActivity extends AppCompatActivity { TextView nome_view = null; TextView email_view = null; private final int ON_ACT_RESULT_CAMERA = 1; private final int ON_ACT_RESULT_GALLERY = 2; private String captured_image_path; int selected = 0; /** * The {@link android.support.v4.view.PagerAdapter} that will provide * fragments for each of the sections. We use a * {@link 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}. */ private SectionsPagerAdapter mSectionsPagerAdapter; /** * The {@link ViewPager} that will host the section contents. */ private ViewPager mViewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); ........................................................................
c'è differenza di metodo tra una Activity (con extends AppCompatActivity) e una con extends fragment?codice:public class Dati1Fragment extends Fragment { public Dati1Fragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_dati1, container, false); } }
Chi mi può dare delucidazioni?
Grazie

Rispondi quotando