0

テキストビューが複数の列に並べられた相対的なレイアウトがあります。画面をクリックすると、「ポップアップ画面」または「入力画面」(どのように呼ばれるかわからない)があり、「開始」と「終了」の時間、学校のクラスの名前などを定義します。その入力からマージする必要のあるテキストビューを計算します。マージされたテキストビューは、1つの大きなテキストビューのようにする必要があります。このようなことは可能ですか?

先に答えてくれてありがとう。

このようなもの:http: //i.stack.imgur.com/r1o8D.png

4

1 に答える 1

0

ビューを使用する代わりに、カスタムビューを作成してこれを描画してみることができると思います。

新しいクラスでViewクラスを拡張し、onDrawメソッドをオーバーライドします。

//variables
Paint paint[]; //Set up these paints with the colors you need
int rowWidth, int colHeight;
void onDraw(Canvas c){
    for(int i=0;i<noOfRows;i++){
       for(int j=0;j<noOfColumns;j++){
            if(cellRequired(i,j)){
              //cellRequired will be whatever logic you have to check if cell is required

                int rectHeight=colHeight; //Now the Rect Height changes whether the cell
                                         //  below is in use or not.
                for(int k=i;k<noOfRows;k++){                         
                     //This loop will run through the rows and see if merging is required
                      if(cellRequired(i,k))
                             rectHeight+=colHeight; //Merge Cell
                      else 
                              break; //If not required at any point break loop
                 }
                 //Draw Rectangle background
                 c.drawRect(i*rowWidth +i, j*colHeight +j, rowWidth, rectHeight, backPaint);
                 //Draw Text
                 canvas.drawText("Text",i*rowWidth +i, j*colHeight +j, paint[requiredPaint]);
                 //I added the plus i and plus j so there'd be a gap in the rectangles
                 // Then it will be a border
            }         
       }
    }
}

カスタムコントロールに関するAndroidのドキュメント

Android:カスタムビュー作成のチュートリアル

上記のようなカスタムビューを作成する方法

http://www.droidnova.com/playing-with-graphics-in-android-part-i,147.html

これらを確認してから、上記のコードを確認してください。うまくいけば、それはそれを実装する方法をあなたに示すはずです。

于 2012-12-06T15:06:26.757 に答える