我是 android 新手,Java 新手,当然还有 achartengine 新手。我已经完成了一个应用程序,用户在其中输入一些数据,我想用这些数据制作一个线图。我必须遵循哪些步骤?
- 导入 achartengine jar 文件。
- 在我的应用程序中使用 abstractdemochart.class 文件。
- 在我的应用程序中使用三角函数图文件。
- 编辑三角函数图表文件以使用我的数据。
我不知道以上是否正确。另外,如果我必须编辑三角函数图文件,我该如何处理 number_cores.class 中的变量(数据)?
这是进行计算的 number_cores.class。用户输入 num_cores、halftime 和 timecores(时间)。
我想用时间与 fcores(cores_func 下面的核心数)做一个图。
(如果我希望时间从 0 到用户输入的时间。)
public class number_cores extends Activity implements OnClickListener
{
EditText num_cores;
EditText halftimecores;
EditText timecores;
View core_calcs;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.numbercores);
num_cores=(EditText) findViewById(R.id.num_cores);
halftimecores=(EditText) findViewById(R.id.halftimecores);
timecores=(EditText) findViewById(R.id.timecores);
core_calcs=(View) findViewById(R.id.core_calcs);
core_calcs.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()){
case R.id.core_calcs:
if(isNumeric(num_cores.getText().toString()) &&
isNumeric(halftimecores.getText().toString()) &&
isNumeric(timecores.getText().toString()))
{
cores_func();
}
else
{
Toast.makeText(number_cores.this, "Please provide
a number", Toast.LENGTH_SHORT).show();
}
break;
}
}
public static boolean isNumeric(String str)
{
try
{
double d = Double.parseDouble(str);
}
catch(NumberFormatException nfe)
{
return false;
}
return true;
}
public void cores_func(){
double
initcores=Double.parseDouble(num_cores.getText().toString().trim());
double
half_time=Double.parseDouble(halftimecores.getText().toString().trim());
double
ttime=Double.parseDouble(timecores.getText().toString().trim());
double l=Math.log(2)/half_time;
double fcores=initcores*Math.exp(-l*ttime);
Intent i=new Intent(this,core_calcs.class);
i.putExtra("value",fcores);
startActivity(i);
}
谢谢!