XML : (TextView) setText() method returns blank, not working

First of all I tried to find solutions through Google, StackOverFlow and other resources. But I couldn't find the solution.

I'm developing Navigation Drawer based Android application. NavMainActivity handles fragments. EventFragment, HomeFragment, ProfileFragment, etc..

I'm using Parse SDK for background jobs. Parse doing its job well. But in EventFragment class, the TextView's setText() method does not do anything. I examine this problem and use Snackbar and Toast to test my background service is working well. And yes, it works well.

  public class EventFragment extends Fragment implements View.OnClickListener {        /*      Initiliazing the params and our view.       */      private static final String ARG_PARAM1 = "param1";      private static final String ARG_PARAM2 = "param2";        View view;        boolean isPressed = false;          private String mParam1;      private String mParam2;      public String eventDescription;      public ParseFile userImage;        private OnFragmentInteractionListener mListener;        public EventFragment() {          // Required empty public constructor      }          public static EventFragment newInstance(String param1, String param2) {          EventFragment fragment = new EventFragment();          Bundle args = new Bundle();          args.putString(ARG_PARAM1, param1);          args.putString(ARG_PARAM2, param2);          fragment.setArguments(args);          return fragment;      }        @Override      public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);              }          @Override      public View onCreateView(LayoutInflater inflater, ViewGroup container,                               Bundle savedInstanceState) {            /*          FloatingAB used for material design guidelines.          We listen for clicks but in this version user can click many times we need to          implement opposite button reaction like " Participate " and " Not Participate " state changes.           */            view= inflater.inflate(R.layout.fragment_event, container, false);            FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);          fab.setOnClickListener(this);            ParseQuery<ParseObject> query = ParseQuery.getQuery("EventData");          query.whereEqualTo("objectId", "uEglVemWEF");          query.getFirstInBackground(new GetCallback<ParseObject>() {              public void done(ParseObject object, ParseException e) {                  if (object == null) {                      Log.d("EventData", "The get the first method request failed!");                    } else {                        eventDescription = object.getString("eventContext");                      userImage = object.getParseFile("eventPhoto");                        Snackbar.make(view, eventDescription, Snackbar.LENGTH_LONG)                              .setAction("Action", null).show();                    }              }          });            TextView z = (TextView)view.findViewById(R.id.eventDescriptionText);          z.setText(eventDescription);            if (ParseUser.getCurrentUser().getBoolean("eventA")) {              fab.setImageResource(R.drawable.ic_highlight_remove_24dp);              isPressed =true;          }            return view;        }    
  <android.support.design.widget.AppBarLayout      android:id="@+id/app_bar"      android:layout_width="match_parent"      android:layout_height="@dimen/app_bar_height"      android:fitsSystemWindows="true"      android:theme="@style/HeyVolo.AppBarOverlay">        <android.support.design.widget.CollapsingToolbarLayout          android:id="@+id/toolbar_layout"          android:layout_width="match_parent"          android:layout_height="match_parent"          android:fitsSystemWindows="true"          app:contentScrim="@color/darkblue"          app:layout_scrollFlags="scroll|exitUntilCollapsed">            <ImageView              android:id="@+id/main.backdrop"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:scaleType="centerCrop"              android:fitsSystemWindows="true"              android:src="@drawable/peace"              app:layout_collapseMode="parallax"                />            </android.support.design.widget.CollapsingToolbarLayout>  </android.support.design.widget.AppBarLayout>        <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:app="http://schemas.android.com/apk/res-auto"      xmlns:tools="http://schemas.android.com/tools"      android:layout_width="match_parent"      android:layout_height="match_parent"      app:layout_behavior="@string/appbar_scrolling_view_behavior"      >          <TextView          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_margin="@dimen/text_margin"          android:id="@+id/eventDescriptionText"          android:text="" />    </android.support.v4.widget.NestedScrollView>    <android.support.design.widget.FloatingActionButton      android:id="@+id/fab"      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_margin="@dimen/fab_margin"      android:src="@drawable/ic_assignment_turned_in_24dp"      app:layout_anchor="@id/app_bar"      app:layout_anchorGravity="bottom|end" />    

By the way I want to set 5-6 sentences long paragraph on my eventDescriptionText TextView.

No comments:

Post a Comment