Closed samsoft00 closed 9 years ago
@samsoft00 Your code seems correct. The latest version of the build has not been pushed to maven yet. You are still using a rather beta edition. There is in fact a bug with the library. It has been fixed. I will push it in momentarily. Thank you for spotting it and I apologize for the problem
Use version 2.0.3. Please look at the samples before you use it. There are some modifications done in order to address previous bugs. Let me know if issues persist.
Use version 2.0.4. Let me know if you still have any issues.
No Crashing again but no text display -> DocumentView documentView = new DocumentView(getActivity(), R.id.instruction); Please help, I'm using fragment layout..
Provide some code
— Sent from Mailbox
On Thu, Jan 15, 2015 at 2:53 AM, Oyewole S. Abayomi notifications@github.com wrote:
No Crashing again but no text display -> DocumentView documentView = new DocumentView(getActivity(), R.id.instruction);
Please help, I'm using fragment layout..
Reply to this email directly or view it on GitHub: https://github.com/bluejamesbond/TextJustify-Android/issues/53#issuecomment-70056144
Here is my code
public class StartRegistrationFragment extends Fragment { private static final String ARG_KEY = "key";
private PageFragmentCallbacks mCallbacks;
private String mKey;
private StartRegistrationActivity mPage;
DocumentView mDocumentView;
ArticleBuilder a;
public static StartRegistrationFragment create(String key) {
Bundle args = new Bundle();
args.putString(ARG_KEY, key);
StartRegistrationFragment fragment = new StartRegistrationFragment();
fragment.setArguments(args);
return fragment;
}
public StartRegistrationFragment(){}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
mKey = args.getString(ARG_KEY);
mPage = (StartRegistrationActivity) mCallbacks.onGetPage(mKey);
a = new ArticleBuilder();
a.append("WHO: Ebola Cases",
false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD))
.append("<font color=0xFFC801>Sam Frizell</font><font color=0x888888> @Sam_Frizell Oct. 25, 2014</font>",
false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
.append("In New York and New Jersey, governors Andrew Cuomo and Chris Christie have implemented controversial quarantines on all healthcare workers returning from West Africa after a doctor returning from Guinea contracted the disease and was diagnosed in New York.",
true, new RelativeSizeSpan(1f), new JustifiedSpan());
DocumentView documentView = new DocumentView(getActivity(), R.id.instruction); // Support spanned text
documentView.setText(a); // Set to `true` to enable justification
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_start_registration, container, false);
((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle());
//mDocumentView = (DocumentView) rootView.findViewById(R.id.instruction);
return rootView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (!(activity instanceof PageFragmentCallbacks)) {
throw new ClassCastException("Activity must implement PageFragmentCallbacks");
}
mCallbacks = (PageFragmentCallbacks) activity;
}
@Override
public void onDetach() {
super.onDetach();
mCallbacks = null;
}
}
This is my view
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:document="http://schemas.android.com/apk/res-auto"
style="@style/WizardPageContainer"
android:orientation="vertical">
<TextView style="@style/WizardPageTitle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/review_icon"
android:layout_gravity="center"
android:padding="10dp"/>
<LinearLayout
android:id="@+id/discription_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:padding="10dp">
<com.bluejamesbond.text.DocumentView
android:id="@+id/instruction"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Your did not add DocumentView to a parent layout
@bluejamesbond DocumentView to a parent layout? where and how?
findViewById(R.id.desriptionWrapper).addView(documentView)
@bluejamesbond i'm sorry, this is getting confused...
This is reference to my layout==> DocumentView mDocumentView = (DocumentView) rootView.findViewById(R.id.instruction);
Where i'm going to reference it here ==> DocumentView documentView = new DocumentView(getActivity(), R.id.instruction); documentView.setText(articleBuilder);
can you help me with sample code! Thanks!
Thanks, it work now but i move the code to onResume()
@Override
public void onResume() {
super.onResume();
a = new ArticleBuilder();
a.append("WHO: Ebola Cases",
false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD))
.append("<font color=0xFFC801>Sam Frizell</font><font color=0x888888> @Sam_Frizell Oct. 25, 2014</font>",
false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
.append("In New York and New Jersey, governors Andrew Cuomo and Chris Christie have implemented controversial quarantines on all healthcare workers returning from West Africa after a doctor returning from Guinea contracted the disease and was diagnosed in New York.",
true, new RelativeSizeSpan(1f), new JustifiedSpan());
DocumentView documentView = new DocumentView(getActivity(), DocumentView.FORMATTED_TEXT); // Support spanned text
documentView.setText(a); // Set to `true` to enable justification
(mLayout).addView(documentView);
}
Thanks
@samsoft00 I don't believe you are supposed to put it in onResume as per Android contract.
@bluejamesbond it crashed when i put it onCreate, remember this is fragment. Also, question. how do i reset the textSize!
I think dere's alot to amend, i later discovered that the article is not fully loaded, only first append contents.. Check code
a = new ArticleBuilder();
a.append("BluSlate Study Studio",
false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD))
.append("The Blue Slate Study Studio is our flagship education solution where the art of teaching, the joy of learning and the proactive anticipation of exams – all co-exist in harmony to produce a positive and gratifying learning experience. The Study Studio application is made of multiple Study Booths. A Study Booth caters exclusively for a course as follows: Course No., Course Name, Course Material, Slide Presentations, Practice Exams, Course Notes and Course Information.",
true, new RelativeSizeSpan(1f), new JustifiedSpan())
.append("<font color=0xFFC801>Course No. Tab:</font> (the first tab) lists the course identifier – e.g. CSC 101.",
true, new RelativeSizeSpan(1f), new JustifiedSpan())
.append("<font color=0xFFC801>Course Name Tab:</font> (the second tab) lists the full name of the course.",
true, new RelativeSizeSpan(1f), new LeftSpan())
.append("<font color=0xFFC801>Course Material Tab: </font> opens up an e-book containing lecture materials content.",
true, new RelativeSizeSpan(1f), new LeftSpan())
.append("<font color=0xFFC801>Slide Presentation Tab: </font> opens into a Power point Slide presentation prepared by lecturer.",
true, new RelativeSizeSpan(1f), new LeftSpan())
.append("<font color=0xFFC801>Practice Exam Tab: </font> opens up to CBC’s Practezer App with content made up of previous sessions exams, answers and correct model solutions. The students can practice in an ad-hoc manner (random questions, untimed) or actually sit for a previous exam (timed). For each question, the student can click a button to see the correct answer, and click another button to get a detailed model solution.",
true, new RelativeSizeSpan(1f), new LeftSpan())
.append("<font color=0xFFC801>Course Notes Tab: </font> opens up a Word document where the student can keep personal notes on the course..",
true, new RelativeSizeSpan(1f), new LeftSpan())
.append("<font color=0xFFC801>Course Info Tab: </font> opens up to general information on the course such as course content, prerequisites, lecturers, as well as the schedule of lectures and labs for the course.",
true, new RelativeSizeSpan(1f), new LeftSpan())
.append("PLEASE NOTE THAT YOU WILL NEED INTERNET ACCESS FOR <font color=0xFFC801>REGISTRATION</font> FOR YOUR FIRST LOGIN",
true, new RelativeSizeSpan(1f), new LeftSpan());
DocumentView documentView = new DocumentView(getActivity(), DocumentView.FORMATTED_TEXT); // Support spanned text
documentView.setText(a);
(mLayout).addView(documentView);
To be honest, i've spent hours trying to find a way to make use of this library and to attached it to view.. it was so difficult, can you help on how?
I want to make use of ArticleBuilder(), so how do i make reference to view where i have this --> <com.bluejamesbond.text.DocumentView xmlns:document="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="+id/instruction" />
here is my java code
Doing it this way generate error
Any Solution on how to relate the view and the java code together, if i'm not doing it right.. please let me know. Thanks