1

私は使用draggable gridviewしていますが、グリッドビューにプログラムでサブビューを追加する必要があり、追加するaddView()メソッドと他のDraw(Canvas)メソッドを試しましたが、機能しません。

subviewのすべてviewに追加する方法を教えてくださいdraggable grid view

String color ="null";
                try
                {
                    word=inCartSongTitleList.get(i).toString();
                    color=inCartColor_List.get(i).toString();
                    time="00.00";
                    if(word.equals("null"))
                    {
                        word="";
                    }
                }
                catch(Exception e)
                {
                    word="ERROR";
                    Log.e("",""+e+"");
                }

                //ImageView view = new ImageView(CartActivity.this);


                LinearLayout view = new LinearLayout(CartActivity.this);
                LinearLayout.LayoutParams trparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                view.setLayoutParams(trparams);
                TextView txt=new TextView(CartActivity.this);

                txt.setText("Mikin");
                txt.setTextColor(Color.parseColor("#ffffff"));


                Canvas canvas = new Canvas();
                Paint paint = new Paint();
                paint.setColor(Color.BLACK);
                paint.setTextAlign(Paint.Align.CENTER);
                canvas.drawText("Mikin",50,50,paint);

                //ImageView view = new ImageView(CartActivity.this);
                //view.setBackgroundResource(R.drawable.sound);
                view.draw(canvas);
                //view.setBackgroundColor(Color.parseColor("#ffffff"));

                if(String.valueOf(color).equals("0"))
                {
                    //view.setBackgroundColor(Color.parseColor("#768CA7"));
                    view.setBackgroundColor(Color.parseColor("#768CA7"));
                    //view.setImageBitmap(getThumb(word,"#768CA7",time));
                }
                else if(color.equals("null"))
                {
                    view.setBackgroundColor(Color.parseColor("#768CA7"));
                    //imageView.setBackgroundColor(Color.parseColor("#768CA7"));
                    //view.setImageBitmap(getThumb(word,"#768CA7",time));               
                }
                else if(color!=null)
                {
                    view.setBackgroundColor(Color.parseColor(color));
                    //imageView.setBackgroundColor(Color.parseColor(color));
                    //view.setImageBitmap(getThumb(word,color,time));
                }
                //view.addView(imageView);
                draggableGrid.addView(view);
4

0 に答える 0