프로그래밍 방식으로 화면에 단추를 추가하고 API
을 구문 분석하여 값을 가져오고 이제 배열의 길이에 따라 단추를 표시하려고합니다. 나는이 일을하고 있지만 마지막 버튼 만 표시되지만, for
루프에서는 모든 값이 정확하지만 마지막 버튼 만 표시됩니다. 당신은 buttom의 상단이 항목의 좌우 추가 할 수 있습니다 x와 Android.you의 y 값을주지해야한다프로그래밍 방식으로 동적 단추 표시
RelativeLayout relate;
//...
relate = (RelativeLayout)findViewById(R.id.relative);
protected void onPostExecute(Void result) {
if(dialog.isShowing() == true) {
dialog.dismiss();
}
//int width = 100, height =50, x = 10, y = 20;
for (int i =0;i<adapt_obj.city_name_array.length;i++){
b1 = new Button(myref);
b1.setText(adapt_obj.city_name_array[i]);
relate.addView(b1);
//relate.addView(b1, i, new RelativeLayout.LayoutParams(width,height));
//height = height+80;
}
listlocation.setAdapter(adapt_obj);
adapt_obj.notifyDataSetChanged();
}
덕분에 많이 U 회신 해 드리겠습니다, 아주 많이 근무 U 감사 : 여기
for
루프의 일부 수정은 – Ved