0
public class Dues extends Activity {
static final String[] alphabets = new String[] {
"A", "B", "C", "D"};
static final String[] alphabets1 = new String[] {
"E", "F", "G", "H"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dues);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, alphabets);
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, alphabets1);
RelativeLayout relativeLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams relativeLayoutParams = new
RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);
GridView gridView= new GridView(this);
gridView.setLayoutParams(new
GridView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
gridView.setNumColumns(4);
gridView.setAdapter(adapter);
Drawable myIcon = getResources().getDrawable(R.drawable.bg);
gridView.setBackground(myIcon);
GridView gridView1 = new GridView(this);
gridView1.setLayoutParams(new
GridView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
gridView1.setNumColumns(4);
gridView1.setAdapter(adapter);
Drawable myIcon = getResources().getDrawable(R.drawable.bg);
gridView1.setBackground(myIcon);
}
}
因此,此代码创建2个gridview,但其重叠。请帮帮我。 ABCD和EFGH都相互重叠。 这样我想添加多个GridView使用滚动查看。 任何人都可以帮助我这个请。 我希望它是可见的一个在另一个之下。如何以编程方式创建多个gridview
gridview的数量是动态的,也没有固定的数量,因此我希望它以编程方式创建,而不是通过xml文件。 也我希望它是绿色透明,所以任何人都可以帮助我也
噢好吧!,非常感谢。我做了wrap_content,但是然后gridview不可见 –
你能帮助它的代码吗? –
按照我说的一步一步来做。你不能使用ScrollView来实现这一点,你必须使用NestedScrollView – Ricardo