Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EventInfo extends FragmentActivity implements
- ActionBar.TabListener {
- JSONObject obj;
- GoogleMap map;
- double latitude, longitude = 0;
- String address = "";
- String titleEvent = "";
- private TextView descriptionText;
- private ViewPager viewPager;
- private TabsPagerAdapter mAdapter;
- private ActionBar actionBar;
- // tab titles
- private String[] tabs = { "Event Info", "Google Map" };
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.eventinfo);
- // Initialization:
- viewPager = (ViewPager) findViewById(R.id.pager);
- actionBar = getActionBar();
- mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
- viewPager.setAdapter(mAdapter);
- actionBar.setHomeButtonEnabled(false);
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- // Adding Tabs
- for (String tab_name : tabs) {
- actionBar.addTab(actionBar.newTab().setText(tab_name)
- .setTabListener(this));
- }
- try {
- obj = new JSONObject(getIntent().getStringExtra("json"));
- Toast.makeText(getApplicationContext(),
- "event = " + obj.getString("summary"), Toast.LENGTH_LONG)
- .show();
- address = obj.getString("location");
- titleEvent = obj.getString("summary");
- } catch (JSONException e) {
- e.printStackTrace();
- }
- //I think the problem is somewhere in this code block!
- LayoutInflater inflater = getLayoutInflater();
- View descripText = inflater.inflate(R.layout.fragment_infofrag, null);
- descriptionText = (TextView) descripText.findViewById(R.id.descriptionText);
- descriptionText.setText("updated text"); //the textView gets updated here!
- Toast.makeText(getApplicationContext(), "display: "+ descriptionText.getText(), Toast.LENGTH_LONG).show(); //Toast box correctly displays, but the textView on the actual tab does not
- }
- package com.uva.tabswipe.adapter;
- import org.json.JSONException;
- import org.json.JSONObject;
- import com.uva.tabswipe.adapter.InfoFragment;
- import com.uva.tabswipe.adapter.GMapFragment;
- import android.support.v4.app.Fragment;
- import android.support.v4.app.FragmentManager;
- import android.support.v4.app.FragmentPagerAdapter;
- public class TabsPagerAdapter extends FragmentPagerAdapter {
- public TabsPagerAdapter(FragmentManager fm) {
- super(fm);
- }
- @Override
- public Fragment getItem(int index) {
- switch (index) {
- case 0:
- // Tab with event info
- return new InfoFragment();
- case 1:
- // Tab with Google Map Fragment (this one is working fine)
- return new GMapFragment();
- }
- return null;
- }
- @Override
- public int getCount() {
- // get item count - equal to number of tabs
- return 2;
- }
- }
- package com.uva.tabswipe.adapter;...
- public class InfoFragment extends Fragment {
- TextView descriptionText;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_infofrag, container, false);
- return rootView;
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#E0EEEE"
- android:gravity="center" >
- <TextView
- android:id="@+id/descriptionText"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="#F88017"
- android:textSize="14sp"
- android:text="" />
- </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement