I'm very new to the android world, coming from a background of lots of server-side programming . Very Little Java.
I am developing an application in which I need to have two fragments, one on the left which displays the navigation, and one on the right, that displays the content. My first major challange is to make one of the navigation links open up a chart using acharengine.
I have an example from achartengine that I have been following here: achartengine example
I have been following the Android Developer application demo provided by google here: Fragment Basics
I am using that example and simply building everything using that existing code. So far, I have narrowed down the actual content display to this code inside ArticleFragment.java:
This is what happens onStart:
public void onStart() {
super.onStart();
// During startup, check if there are arguments passed to the fragment.
// onStart is a good place to do this because the layout has already been
// applied to the fragment at this point so we can safely call the method
// below that sets the article text.
Bundle args = getArguments();
if (args != null) {
// Set article based on argument passed in
updateArticleView(args.getInt(ARG_POSITION));
} else if (mCurrentPosition != -1) {
// Set article based on saved instance state defined during onCreateView
updateArticleView(mCurrentPosition);
}
}
public void updateArticleView(int position) {
TextView article = (TextView) getActivity().findViewById(R.id.article);
article.setText(Ipsum.Articles[position]);
System.out.println("Position: " + position);
mCurrentPosition = position;
}
This is what is inside Ipsum.java:
package com.example.android.fragments;
public class Ipsum {
static String[] Headlines = {
"Link One",
"Link Two",
"Link Three"
};
static String[] Articles = {
"Link One\n\n Some Text...",
"Link Two\n\n Some Text...",
"Link Three\n\n Some Text..."
};
}
When you click one of the "Links" I want the chart to show up inside the other fragment. I'm sure this is simple, and I have tried modifying the code inside updateArticleView to textViews with limited success due to my lack of syntactical knowledge.
I have tried searching, and there have been some helpful examples, but they all have been from the perspective of someone who knows exactly what he/she is doing. I am brand new to this(3 or so weeks) so please dumb it down for me. Thank you.
After hours spent on this issue I finally found the answer in GitHub.
Please go here, navigate to /src/org/elasticdroid/fragments/ChartFragment.java and that's it.
You can easily copy/paste this code and with little play around it will work great.
You can search for AChartEngine on youtube and you will find there some video tutorials on how to start using the charting library.
I also suggest you take a look at the official AChartEngine demo here.
Also, to answer your question, in order to figure out how to embed a chart inside a view with other components, please see this post.