我的问题是,从几天前开始,我的 androidPlot 图形运行良好,我以简单的布局将图形内的所有数据悲伤,但是,我合并了一个库“Viewpagerindicator”,以更好地处理资金的进入和退出关系, 然后, 一切正常, 只是现在看不到图形里面的元素, 这里有图片点击这里
“Ingreso”和“Egreso”是我在我的主要布局中添加的两个布局,是两个活动,我在我的图形“Egreso”或“Ingreso”类中没有触及任何东西,只是添加它们。我不明白为什么我看不到它。
我认为这是我的主要 laoyut 中的 viewpager 标签中的内容,因为我在其他简单的布局中使用它,我看到了图形。请帮忙。附加我的代码。
主要布局 (acitivity_movimientos.xml)
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/CustomTitlePageIndicator"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:paddingBottom="5dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="5dp" />
activity_movimiento_ingresos.xml
<com.androidplot.xy.XYPlot
android:id="@+id/grafica_ingresos"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
androidPlot.title="Ingresos de Enero"
androidPlot.domainLabel="Dias"
androidPlot.rangeLabel="Ingresos"/>
我的班级 MovimientosActivity.java
public class MovimientosActivity extends Activity {
private ViewPager viewPager;
private LinearLayout ingresos;
private LinearLayout egresos;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movimientos);
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#008AFF")));
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(new MainPageAdapter());
TitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
//TabPageIndicator titleIndicator = (TabPageIndicator)findViewById(R.id.indicator);
titleIndicator.setViewPager(viewPager);
titleIndicator.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position){}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels){}
@Override
public void onPageScrollStateChanged(int state){}
});
}
class MainPageAdapter extends PagerAdapter
{
@Override
public CharSequence getPageTitle(int position)
{
String title = null;
switch (position)
{
case 0:
title = getString(R.string.ingresos);
break;
case 1:
title = getString(R.string.egresos);
break;
}
return title;
}
@Override
public int getCount()
{
return 2;
}
@Override
public Object instantiateItem(ViewGroup collection, int position)
{
View page = null;
switch (position)
{
case 0:
if (ingresos == null)
{
ingresos = (LinearLayout) LayoutInflater.from(MovimientosActivity.this).inflate(R.layout.activity_movimiento_ingresos, null);
}
page = ingresos;
break;
case 1:
if (egresos == null)
{
egresos = (LinearLayout) LayoutInflater.from(MovimientosActivity.this).inflate(R.layout.activity_movimiento_egresos, null);
}
page = egresos;
break;
}
((ViewPager) collection).addView(page, 0);
return page;
}
@Override
public boolean isViewFromObject(View view, Object object)
{
return view == object;
}
@Override
public void destroyItem(View collection, int position, Object view)
{
((ViewPager) collection).removeView((View) view);
}
我的班级 MovimientoIngresoActivity.java
public class MovimientoIngresosActivity extends Activity {
private XYPlot plot;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movimiento_ingresos);
plot = (XYPlot) findViewById(R.id.grafica_ingresos);
//CREAMOS DOS ARREGLOS PARA MOSTRAR LOS DATOS, SUSTITUIR POR DATOS REALES LUEGO
Number[] series1Numeros = {1, 8, 5, 2, 7, 4};
Number[] series2Numeros = {4, 6, 3, 8, 2, 10};
Number[] series3Numeros = {3, 5, 7, 4, 6, 8};
//AÑADIMOS LINEA 1
XYSeries series1 = new SimpleXYSeries(
Arrays.asList(series1Numeros), //ARRAY, VALORES VERTICALES, NOMBRE DE LA LINEA
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Intereses");
//AÑADIMOS LINEA 2
XYSeries series2 = new SimpleXYSeries(
Arrays.asList(series2Numeros), //ARRAY, VALORES VERTICALES, NOMBRE DE LA LINEA
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Alquileres");
//AÑADIMOS LINEA 3
XYSeries series3 = new SimpleXYSeries(
Arrays.asList(series3Numeros), //ARRAY, VALORES VERTICALES, NOMBRE DE LA LINEA
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Sansiones");
//MODIFICAMOS LOS COLORES DE LA PRIMERA SERIE
LineAndPointFormatter series1Format = new LineAndPointFormatter(
Color.rgb(0, 200, 0), //COLOR LINEA
Color.rgb(0, 100, 0), //COLOR DEL PUNTO
null, null); //RELLENO
//LO AÑADIMOS AL PANEL
plot.addSeries(series1, series1Format);
//MODIFICAMOS LOS COLORES DE LA SEGUNDA SERIE
LineAndPointFormatter series2Format = new LineAndPointFormatter(
Color.rgb(0, 0, 200), //COLOR LINEA
Color.rgb(0, 0, 100), //COLOR DEL PUNTO
null, null); //RELLENO
//LO AÑADIMOS AL PANEL
plot.addSeries(series2, series2Format);
//MODIFICAMOS LOS COLORES DE LA SEGUNDA SERIE
LineAndPointFormatter series3Format = new LineAndPointFormatter(
Color.rgb(200, 0, 0), //COLOR LINEA
Color.rgb(100, 0, 0), //COLOR DEL PUNTO
null, null); //RELLENO
//LO AÑADIMOS AL PANEL
plot.addSeries(series3, series3Format);
}
}
谢谢