2013-03-19 3 views
3

문제는 아주 분명하다 내부 GraphView에 표시되지 않습니다 X와 Y에 대한 정보와 그래프의 제목이 표시됩니다.X와 Y의 레이블은 단편

public class Chart extends Activity { 

@Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.chart); 

    //UNDER CONSTRUCTION 
    GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] { 
      new GraphViewData(1, 2.0d) 
      , new GraphViewData(2, 1.5d) 
      , new GraphViewData(3, 2.5d) 
      , new GraphViewData(4, 1.0d) 
    }); 

    GraphView graphView = new BarGraphView( 
      this // context 
      , "GraphViewDemo" // heading 
    ); 
    graphView.addSeries(exampleSeries); // data 
    graphView.setBackgroundColor(Color.BLACK); 

    LinearLayout layout = (LinearLayout) findViewById(R.id.chart); 
    layout.addView(graphView); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.activity_main, menu); 
    return true; 
    } 

} 

조각 : 조각에서

는 만 graphe은 ...

활동, X 및 Y 축도 타이틀에 대한 정보를 보여되지

public class ChartFragment extends Fragment { 

GraphView graphView; 
LinearLayout layout; 

// Parameterless constructor is needed by framework 
public ChartFragment() { 
    super(); 
} 

/** 
* Sets up the UI. It consists if a single WebView. 
*/ 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
    layout = new LinearLayout(getActivity()); 
    return layout; 
} 

public void displayChart(int mCatIndex, int mPeriodIndex) { 

    int num = 150; 
    GraphViewData[] data = new GraphViewData[num]; 
    double v=0; 
    for (int i=0; i<num; i++) { 
     v += 0.2; 
     data[i] = new GraphViewData(i, Math.sin(v)); 
    } 
    graphView = new LineGraphView( 
      null 
      , "GraphViewDemo" 
    ); 
    // add data 
    graphView.addSeries(new GraphViewSeries(data)); 
    // set view port, start=2, size=40 
    graphView.setViewPort(2, 40); 
    graphView.setScrollable(true); 
    // optional - activate scaling/zooming 
    graphView.setScalable(true); 
    layout.addView(graphView); 
} 

} 

무엇 문제가 될 수 있습니까?

편집 및 해결 방법 :

어리석은 실수 : X 및 Y 레이블은 처음 레이아웃에서 내 배경 OK> 내 조각에서

검은 ==했다 ... 화이트 색상에 모두 , 배경은 흰색 ==> 첫 번째 예제에서는 X 및 Y 레이블

답변

0

을 볼 수 없으며 레이아웃에 LinearLayout이 정의되어 있습니다 (/ height 매개 변수로 고정 될 가능성이 있음). 고정 너비/높이 값을 사용하여 단편에서 LL을 정의하십시오.

관련 문제