调用acharengine片段内 [英] calling acharengine inside fragment

查看:139
本文介绍了调用acharengine片段内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是很新的Andr​​oid的世界,从大量的服务器端编程的背景的。很少的Java。

我正在开发中,我需要有两个片段,一个在其中显示导航左边,一个在右边,显示的内容的应用程序。 我的第一次重大challange就是让导航链接,打开使用acharengine图表。

我有achartengine我一直在关注这里的一个例子: achartengine

我一直在关注谷歌通过这里提供的Andr​​oid开发应用演示:片段基础

我使用的例子,简单地构建利用一切现有的code。到目前为止,我已经缩小的实际内容显示到内ArticleFragment.java这个code:

这是什么情况ONSTART:

 公共无效ONSTART(){
    super.onStart();

    //在启动过程中,检查是否有参数传递给片段。
    // ONSTART是一个很好的地方,这样做是因为布局已经被
    //应用到的片段在这一点上,所以我们可以安全地调用该方法
    //下面,设置文章全文。
    捆绑的args = getArguments();
    如果(参数!= NULL){
        //设置文章基础上,通过论证
        updateArticleView(args.getInt(ARG_POSITION));
    }否则如果(mCurrentPosition!= -1){
        //设置文章基于onCreateView期间定义保存实例状态
        updateArticleView(mCurrentPosition);
    }
}

公共无效updateArticleView(INT位置){

    TextView的文章=(TextView中)getActivity()findViewById(R.id.article)。
    article.setText(Ipsum.Articles [位置]);
    的System.out.println(位置:+位置);
    mCurrentPosition =位置;
}
 

这是里面是什么Ipsum.java:

 包com.example.android.fragments;
 

公共类存有{

 静态的String []标题= {
    链接一,
    链接二,
    链接三
};


静态的String []文章= {
    链接的一个\ñ\ñ一些文本......,
    连接两个\ñ\ñ一些文本......,
    链接三\ñ\ñ一些文本......
};
 

}

当您单击其中的链接一个我想要的图表显示了另一个片段中。 我敢肯定,这是简单的,我曾尝试修改内部updateArticleView的code到textViews有限的成功,由于我缺乏语法知识。

我已经尝试搜索,并出现了一些有用的例子,但他们都已经从人谁知道正是他/她正在做的视角。我是全新的,以本(3左右周),所以请哑下来我。谢谢你。

解决方案

您可以搜索AChartEngine在YouTube上,你会发现那里如何开始使用图表库的一些视频教程。

我也建议你看看官方AChartEngine演示这里

此外,要回答你的问题,为了弄清楚如何嵌入与其他部件的视图里面的图表,请参阅本<一href="http://stackoverflow.com/questions/4062161/android-i-am-using-achartengine-library-for-graphs-but-not-able-to-integrate-a/4079692#4079692">post.

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.

解决方案

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.

这篇关于调用acharengine片段内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆