안드로이드 개발 질문/답변
(글 수 45,052)
구현할 내용 : 랭킹 레이아웃을 동적으로 구현
문제점 :
서버로 부터 랭킹데이터를 얻어와서 레이아웃을 구성해야되는데 어찌해야하는지 모르겠음
기본 레이아웃
---------------------
순위 이름 점수
서버로부터 데이터를 받아온 뒤
순위 이름 점수
1 가나다 10
2 리리리 8
이런식으로 동적으로 레이아웃이 구성되야합니다.
현제 기본레이아웃은 순위 이름 점수 를 그림파일로 만들어서 전체 레이아웃(Relative)에 백그라운드 이미지로 심어놓은 상태이구요..
랭킹갯수는 그떄그때 다른 데 어떤식으로 동적으로 레이아웃을 구현해야될지 모르겠습니다..
시간적 여유가 되신다면 코드로 알려주...세요.ㅠㅠ
2011.01.12 10:31:47
동적? 훔....... 그냥 코딩으로 view를 생성해서 addView 하면 그게 동적아닌가요.
row 개수 만큼돌면서 해당된 view만들어서 컨테이너에 addView 하면 그게 동적이져-_-
2011.01.12 10:32:40
public static void showToast( Context context,String title){
Toast toast = Toast.makeText(context, title, Toast.LENGTH_SHORT);
toast.setGravity( Gravity.CENTER , 0, 0 );
toast.show();
}
public static void showMessage( Context context, String title, String message )
{
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setIcon(android.R.drawable.ic_dialog_alert);
alert.setTitle(title);
alert.setMessage(message);
alert.setPositiveButton("OK", null);
alert.show();
/*
Toast ast = Toast.makeText( context, message, duration);
ast.setGravity(Gravity.CENTER, 0, 0);
ast.show();
*/
}
public static ArrayList<KCustomPackage_DTO> getsyncPackageList()
{
String id = KGlobal.custUseID;
int serviceCode = KGlobal.service_List.get(KGlobal.service_Position).getSERVICECODE();
KGlobal.package_List =DATAManager.getInstance().getCustom_totalList(id,serviceCode);
return package_List;
}
public static ArrayList<KCustomService_DTO> getsyncServiceList() {
// TODO Auto-generated method stub
String id = KGlobal.custUseID;
KGlobal.service_List =DATAManager.getInstance().getCustom_serviceList(id);
return service_List;
}
public static ViewFlipper creativeFlipper(Context context){
return creativeFlipper(context,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
}
public static ViewFlipper creativeFlipper(Context context,int width_parent,int height_parent){
return creativeFlipper(context, width_parent, height_parent, 0, 0,0,0);
}
public static ViewFlipper creativeFlipper(Context context,int width_parent,int height_parent,ArrayList<View> addView,int in_ani,int out_ani){
ViewFlipper flipper = creativeFlipper(context, width_parent, height_parent, 0, 0,0,0);
for(int i = 0 ; i < addView.size();i++)
flipper.addView(addView.get(i));
KGlobal.setAnimation(context, flipper,in_ani, out_ani);
return flipper;
}
public static ViewFlipper creativeFlipper(Context context,int width_parent,int height_parent,int left_margin,int right_margin,int top_margin,int bottom_margin){
ViewFlipper root = new ViewFlipper(context);
ViewFlipper.LayoutParams params = new ViewFlipper.LayoutParams(
width_parent,
height_parent);
params.leftMargin = left_margin;
params.rightMargin = right_margin;
params.topMargin = top_margin;
params.bottomMargin = bottom_margin;
root.setLayoutParams(params);
// root.setGravity(gravity);
// root.setOrientation(orientation);
return root;
}
public static Gallery creativeGallery(Context context,int gravity){
return creativeGallery(context, gravity,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
}
public static Gallery creativeGallery(Context context,int gravity,int width_parent,int height_parent){
Gallery root = new Gallery(context);
Gallery.LayoutParams params = new Gallery.LayoutParams(
width_parent,
height_parent);
// params.leftMargin = left_margin;
// params.rightMargin = right_margin;
// params.topMargin = top_margin;
// params.bottomMargin = bottom_margin;
root.setLayoutParams(params);
root.setGravity(gravity);
// root.setOrientation(orientation);
return root;
}
public static ViewGroup.LayoutParams setViewGroup_Layoutparam(View view,int width_parent,int height_parent){
ViewGroup.LayoutParams param = new ViewGroup.LayoutParams (width_parent, height_parent);
view.setLayoutParams(param);
return param;
}
public static Drawable getDrawable(Activity context, int res){
Resources resource =context.getResources();
return resource.getDrawable(res);
}
public static String getString(Activity context, int res){
Resources resource =context.getResources();
return resource.getString(res).toString();
}
public static ViewGroup.LayoutParams setParent_Layoutparam(View view,int width_parent,int height_parent){
ViewGroup.LayoutParams param = (ViewGroup.LayoutParams )view.getLayoutParams();
param.width=width_parent;
param.height= height_parent;
view.setLayoutParams(param);
return param;
}
public static void setChild_LinearLayoutparam(LinearLayout layout,int width_parent,int height_parent,float weight){
setChild_LinearLayoutparam(layout, width_parent, height_parent, weight,0,0,0,0);
}
public static void setChild_LinearLayoutparam(LinearLayout layout,int width_parent,int height_parent,float weight,int leftMargin,int rightMargin,int topMargin,int bottomMargin){
for(int i = 0 ; i<layout.getChildCount();i++){
View view= layout.getChildAt(i);
LinearLayout.LayoutParams param = (LinearLayout.LayoutParams )view.getLayoutParams();
param.width=width_parent;
param.height= height_parent;
param.weight=weight;
param.leftMargin = leftMargin;
param.rightMargin = rightMargin;
param.topMargin = topMargin;
param.bottomMargin = bottomMargin;
view.setLayoutParams(param);
}
}
public static ViewGroup.LayoutParams setLinearLayoutparam(LinearLayout view,int width_parent,int height_parent,float weight,int orientation){
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(width_parent, height_parent,weight);
param.width=width_parent;
param.height= height_parent;
view.setOrientation(orientation);
view.setLayoutParams(param);
return view.getLayoutParams();
}
public static ViewGroup.LayoutParams setParent_LinearLayoutparam(View view,int width_parent,int height_parent,float weight){
return setParent_LinearLayoutparam(view, width_parent, height_parent, weight,0,0,0,0);
}
public static ViewGroup.LayoutParams setParent_LinearLayoutparam(View view,int width_parent,int height_parent,float weight,int leftMargin,int rightMargin,int topMargin,int bottomMargin){
LinearLayout.LayoutParams param = (LinearLayout.LayoutParams )view.getLayoutParams();
param.width=width_parent;
param.height= height_parent;
param.weight=weight;
param.leftMargin = leftMargin;
param.rightMargin = rightMargin;
param.topMargin = topMargin;
param.bottomMargin = bottomMargin;
view.setLayoutParams(param);
return param;
}
public static Location getGPS(Activity context){
LocationManager locationManager=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(criteria, true);
if(provider==null){
return null;
}
Location location = locationManager.getLastKnownLocation(provider);
// locationManager.requestLocationUpdates(provider, 1000, 5, loclistener); 업데이트할때 리스너 달수있는 구분.
if(location==null)
return null;
// location.getLatitude() 이처럼 함수 불러다 사용
// location.getLongitude()
return location;
}
public static ViewGroup.LayoutParams setParent_FrameLayoutparam(View view,int width_parent,int height_parent){
return setParent_FrameLayoutparam(view, width_parent, height_parent, 0,0,0,0);
}
public static ViewGroup.LayoutParams setParent_FrameLayoutparam(View view,int width_parent,int height_parent,int leftMargin,int rightMargin,int topMargin,int bottomMargin){
FrameLayout.LayoutParams param = (FrameLayout.LayoutParams )view.getLayoutParams();
param.width=width_parent;
param.height= height_parent;
param.leftMargin = leftMargin;
param.rightMargin = rightMargin;
param.topMargin = topMargin;
param.bottomMargin = bottomMargin;
view.setLayoutParams(param);
return param;
}
public static void setChild_Weight(LinearLayout layout,float weight){
for(int i =0;i<layout.getChildCount();i++){
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) layout.getChildAt(i).getLayoutParams();
params.weight = weight;
layout.getChildAt(i).setLayoutParams(params);
}
}
public static LinearLayout creativeLinearLayout_Freame(Context context,int orientation,int suborientation,int width_parent,int height_parent,int step){
LinearLayout container = KGlobal.creativeLinearLayout(context,orientation, Gravity.CENTER,width_parent,height_parent);
for(int i = 0 ; i < step ;i ++){
ViewGroup temp_container = KGlobal.creativeLinearLayout(context, suborientation, Gravity.LEFT,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
temp_container.setId(i);
container.addView(temp_container);
}
if(orientation==LinearLayout.VERTICAL)
setChild_LinearLayoutparam(container, ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT, 1);
else
setChild_LinearLayoutparam(container, ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.FILL_PARENT, 1);
return container;
}
public static LinearLayout creativeLinearLayout(Context context,int orientation,int gravity,int width_parent,int height_parent,int backcolor){
LinearLayout layout = creativeLinearLayout(context, orientation, gravity, width_parent, height_parent, 0, 0,0,0);
layout.setBackgroundColor(backcolor);
return layout;
}
public static LinearLayout creativeLinearLayout(Context context,int orientation,int gravity){
return creativeLinearLayout(context, orientation, gravity,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
}
public static LinearLayout creativeLinearLayout(Context context,int orientation,int gravity,int width_parent,int height_parent){
return creativeLinearLayout(context, orientation, gravity, width_parent, height_parent, 0, 0,0,0);
}
public static LinearLayout creativeLinearLayout(Context context,int orientation,int gravity,int width_parent,int height_parent,int left_margin,int right_margin,int top_margin,int bottom_margin){
LinearLayout root = new LinearLayout(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
width_parent,
height_parent, 0.0F);
params.leftMargin = left_margin;
params.rightMargin = right_margin;
params.topMargin = top_margin;
params.bottomMargin = bottom_margin;
// params.gravity = gravity;
root.setLayoutParams(params);
root.setGravity(gravity);
root.setOrientation(orientation);
return root;
}
public static ScrollView creativeScrollView(Context context){
return creativeScrollView(context,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
}
public static ScrollView creativeScrollView(Context context,int width_parent,int height_parent){
ScrollView root = new ScrollView(context);
ScrollView.LayoutParams params = new ScrollView.LayoutParams(
width_parent,
height_parent);
root.setLayoutParams(params);
return root;
}
public static FrameLayout creativeFrameLayout(Context context, int width_parent,int height_parent){
FrameLayout root = new FrameLayout(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
width_parent,
height_parent);
root.setLayoutParams(params);
return root;
}
public static ImageView creativeImageView(Context context, int img){
return creativeImageView(context, img,50,50);
}
public static ImageView creativeImageView(Context context, int img,int width, int height){
ImageView root = new ImageView(context);
root.setImageResource(img);
root.setMinimumHeight(height);
root.setMaxHeight(height);
root.setMinimumWidth(width);
root.setMaxWidth(width);
return root;
}
public static void setAlpha(Drawable draw,int alpha ){
draw.setAlpha(alpha);
draw.invalidateSelf();
}
public static void setFilter(Drawable draw,ColorFilter filter ){
draw.setColorFilter( filter);
}
public static void setClearFilter(Drawable draw){
draw.clearColorFilter();
}
public static void setGrayFilter(Drawable draw){
ColorMatrix cm = new ColorMatrix(
new float[] {
0.299f, 0.587f, 0.114f, 0, 0,
0.299f, 0.587f, 0.114f, 0, 0,
0.299f, 0.587f, 0.114f, 0, 0,
0, 0, 0, 1, 0 }
);
setMatrixColorFilter(cm,draw);
}
public static void setReverseFilter(Drawable draw){
ColorMatrix cm = new ColorMatrix(
new float[] {
-1, 0, 0, 0, 255,
0, -1, 0, 0, 255,
0, 0, -1, 0, 255,
0, 0, 0, 1, 0 }
);
setMatrixColorFilter(cm,draw);
}
public static void setMatrixColorFilter(ColorMatrix matrix,Drawable draw){
draw.setColorFilter( new ColorMatrixColorFilter(matrix));
draw.invalidateSelf();
}
public static void setColorFilter(Drawable draw,int color) {
// Mode t = PorterDuff.Mode.MULTIPLY;
setColorFilter(draw,color, PorterDuff.Mode.MULTIPLY);
}
public static void setColorFilter(Drawable draw,int color, PorterDuff.Mode mod) {
draw.setColorFilter(new PorterDuffColorFilter(color, mod));
draw.invalidateSelf();
}
public static View creativeLayout(Context context,int layout){
LayoutInflater inflater = (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(layout, null);
}
public static TextView creativeTextView(Context context, String text){
return creativeTextView(context, text, 15, Color.WHITE);
}
public static TextView creativeTextView(Context context, String text,int fontsize){
return creativeTextView(context, text, fontsize, Color.WHITE);
}
public static TextView creativeTextView(Context context, String text,int fontsize,int fontcolor){
return creativeTextView(context, text, fontsize, fontcolor, 0);
}
public static TextView creativeTextView(Context context, String text,int fontsize,int fontcolor,int backgroundres){
return creativeTextView(context, text, fontsize, fontcolor, backgroundres, Gravity.CENTER);
}
public static TextView creativeTextView(Context context, String text,int fontsize,int fontcolor,int backgroundres,int gravity){
TextView root =new TextView(context);
root.setText(text);
root.setTextSize(fontsize);
root.setGravity(gravity);
root.setTextColor(fontcolor);
if(backgroundres>0){
try{
root.setBackgroundResource(backgroundres);
}catch(Exception e){
root.setBackgroundColor(backgroundres);
}
}
return root;
}
public static TextView creativeTextView(Context context, Spanned text){
return creativeTextView(context, text, 15, Color.WHITE);
}
public static TextView creativeTextView(Context context, Spanned text,int fontsize){
return creativeTextView(context, text, fontsize, Color.WHITE);
}
public static TextView creativeTextView(Context context, Spanned text,int fontsize,int fontcolor){
return creativeTextView(context, text, fontsize, fontcolor, 0);
}
public static TextView creativeTextView(Context context, Spanned text,int fontsize,int fontcolor,int background_res){
TextView root =new TextView(context);
root.setText(text);
root.setTextSize(fontsize);
root.setGravity(Gravity.CENTER);
root.setTextColor(fontcolor);
if(background_res>0){
try{
root.setBackgroundResource(background_res);
}catch(Exception e){
root.setBackgroundColor(background_res);
}
}
return root;
}
public static Dialog creativeDialog(Activity context,View addView){
return creativeDialog(context, addView, null);
}
public static Dialog creativeDialog(Activity context,View addView,String title){
return creativeDialog(context, addView, title, null);
}
public static Dialog creativeDialog(Activity context,View addView,String title,ArrayList<Button> button){
return creativeDialog(context, addView, title, ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,button);
}
public static Dialog creativeDialog(Activity context,View addView,String title,int width, int height){
return creativeDialog(context, addView, title, width,height,null);
}
public static Dialog creativeDialog(Activity context,View addView,String title,int width, int height,ArrayList<Button> button){
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.setContentView(R.layout.custom_dialog);
if(title!=null){
((TextView)dialog.findViewById( R.id.title_text)).setVisibility(View.VISIBLE);
((TextView)dialog.findViewById( R.id.title_text)).setText(title);
}
((LinearLayout)dialog.findViewById( R.id.dialog_container)).addView(addView);
((Button)dialog.findViewById( R.id.cancel_btn )).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
LinearLayout dialog_layout = (LinearLayout) dialog.findViewById(R.id.dialog_layout);
if(ViewGroup.LayoutParams.FILL_PARENT==width)
width=KGlobal.getWindowWidth(context)-30;
if(ViewGroup.LayoutParams.FILL_PARENT==height)
height=KGlobal.getWindowHeight(context)-30;
setLinearLayoutparam(dialog_layout, width, height, 0, LinearLayout.VERTICAL);
//button list add
if(button!=null){
for(int i = 0 ; i <button.size();i++){
Button btn = button.get(i);
btn.setTextColor(0xFF999999);
btn.setBackgroundResource(R.drawable.btn_darkgraybg);
btn.setPadding(15, 0, 15, 0);
((ViewGroup) dialog.findViewById(R.id.button_layout)).addView(btn,0);
KGlobal.setParent_Layoutparam(btn, ViewGroup.LayoutParams.WRAP_CONTENT,60);
}
}
return dialog;
}
public static Dialog creativeDialog(Context context,int layout){
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.setContentView(layout);
return dialog;
}
public static Dialog creativeCustomDialog(Context context, int layout){
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.setContentView(layout);
((Button)dialog.findViewById( R.id.cancel_btn )).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
return dialog;
}
public static ViewGroup addView(ViewGroup viewgroup,View view, ViewGroup.LayoutParams param){
// ((ViewFlipper)getComponent(R.id.custom_flipper)).addView(listview,
// new ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.FILL_PARENT,
// ViewGroup.LayoutParams.FILL_PARENT));
viewgroup.addView(view,param);
return viewgroup;
}
public static void setTitle(Activity context , String titlemsg){
context.setTitle(titlemsg);
}
public static void setWindowNoTitle(Activity context){
setWindowFeature(context, Window.FEATURE_NO_TITLE);
}
public static void setWindowFeature(Activity context ,int windowFeature){
// context.requestWindowFeature(Window.FEATURE_NO_TITLE);
context.requestWindowFeature(windowFeature);
}
public static ProgressDialog creativeProgressBar (Context context){
return creativeProgressBar(context,null);
}
public static ProgressDialog creativeProgressBar (Context context,String comment){
ProgressDialog dialog = new ProgressDialog(context);
if(comment==null)
dialog.setMessage("Please wait while loading...");
else
dialog.setMessage(comment);
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
public static int availableCommunication(Context context){
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
boolean isWifiAvail = ni.isAvailable();
boolean isWifiConn = ni.isConnected();
ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
boolean isMobileAvail = ni.isAvailable();
boolean isMobileConn = ni.isConnected();
String status = "WiFi\nAvail = " + isWifiAvail + "\nConn = "
+ isWifiConn + "\nMobile\nAvail = " + isMobileAvail
+ "\nConn = " + isMobileConn + "\n";
Log.d("Communication State! ",status);
if(isWifiAvail == true && isWifiConn == true){
return ConnectivityManager.TYPE_WIFI;
}else if(isMobileAvail == true && isMobileConn == true){
return ConnectivityManager.TYPE_MOBILE;
}else{
return -1;
}
}
public static String getPhoneNumber(Context context)
{
TelephonyManager tMgr =(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String phone = "";
try{
if(tMgr.getLine1Number()!=null){
phone = tMgr.getLine1Number();
}
phone = phone.substring(phone.length()-10,phone.length());
phone="0"+phone;
}catch(Exception e){
e.printStackTrace();
}
// Log.d("Phone Number ",phone);
// phone="01050950425";
return phone;
}
public static void goPage(Context context, Class gopage){
Intent intent = new Intent(context, gopage);
context.startActivity(intent);
}
public static void goPage(Context context,Class gopage,String extraName , String extraValue){
Intent intent = new Intent(context, gopage);
intent.putExtra(extraName,extraValue);
context.startActivity(intent);
}
public static void goPage(Context context,Class gopage,String extraName , int extraValue){
Intent intent = new Intent(context, gopage);
intent.putExtra(extraName,extraValue);
context.startActivity(intent);
}
public static void callDial(Context context,String dial_number){
Intent phonepassIntent = new Intent();
phonepassIntent.setAction(Intent.ACTION_DIAL);
phonepassIntent.setData(Uri.parse("tel:"+dial_number));
context.startActivity(phonepassIntent);
}
public static int requestGetParameter_toInt(Activity context,String extraName){
Intent intent = context.getIntent();
return intent.getIntExtra(extraName,-1);
}
public static String requestGetParameter_toString(Activity context,String extraName){
Intent intent = context.getIntent();
return intent.getStringExtra(extraName);
}
public static void goTabChange(TabActivity tabactivity,String tabname){
tabactivity.getTabHost().setCurrentTabByTag(tabname);
// customDB c = (customDB) p.getCurrentActivity();
// c.importData(atItem);
}
public static void goTabChange(Activity context,String tabname){
TabActivity p = (TabActivity)context.getParent();
p.getTabHost().setCurrentTabByTag(tabname);
// customDB c = (customDB) p.getCurrentActivity();
// c.importData(atItem);
}
public static void goTabChange(Activity context,int index){
TabActivity p = (TabActivity)context.getParent();
p.getTabHost().setCurrentTab(index);
}
public static ListView creativeListView(Context context){
return creativeListView(context, 1);
}
public static ListView creativeListView(Context context, int dividerheight){
ListView listview = new ListView(context);
listview.setScrollingCacheEnabled(false);
listview.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT));
listview.setDividerHeight(0);
return listview;
}
public static Button creativeButton (Context context,String text){
Button btn =new Button(context);
btn.setText(text);
return btn;
}
public static Button creativeButton (Context context,String text,int textColor){
Button btn = creativeButton(context,text);
btn.setTextColor(textColor);
return btn;
}
public static LinearLayout creativeRow(Context context,String[] columninfo,int textSize,int[] textColor,int gravity, float[] weight,int width_parent, int height_parent) {
// View[] views = new View[columnname.length];
// float[] weight={11,10,10,10,10};
// LinearLayout tableHeadlayout = KGlobal.creativeLinearLayout(context, LinearLayout.HORIZONTAL, Gravity.CENTER,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
LinearLayout tableHeadlayout = KGlobal.creativeLinearLayout(context, LinearLayout.HORIZONTAL, Gravity.CENTER,width_parent,height_parent);
// tableHeadlayout.setBackgroundResource(R.drawable.tablehead);
for(int i =0 ; i < columninfo.length;i++){
TextView text = KGlobal.creativeTextView(context, columninfo[i],textSize,textColor[i]);
text.setGravity(gravity);
LinearLayout hline = KGlobal.creativeLinearLayout(context, LinearLayout.HORIZONTAL, Gravity.CENTER,1,ViewGroup.LayoutParams.FILL_PARENT);
hline.setBackgroundColor(0xff555555);
if(i!=0)
tableHeadlayout.addView(hline);
tableHeadlayout.addView(text);
if(weight==null)
KGlobal.setParent_LinearLayoutparam(text,ViewGroup.LayoutParams.FILL_PARENT ,ViewGroup.LayoutParams.FILL_PARENT,1);
else
KGlobal.setParent_LinearLayoutparam(text,ViewGroup.LayoutParams.FILL_PARENT ,ViewGroup.LayoutParams.FILL_PARENT,weight[i]);
// views[i] = text;
}
return tableHeadlayout;
}
public static Button creativeButton (Context context,String text,int textcolor,int background_res){
Button btn = creativeButton(context,text);
btn.setBackgroundResource(background_res);
btn.setTextColor(textcolor);
return btn;
}
public static Button creativeButton (Context context,String text,int textcolor,int background_res,int width,int height){
Button btn = creativeButton(context,text,textcolor,background_res);
btn.setWidth(width);
btn.setHeight(height);
return btn;
}
public static void setChildsAlphaListener(ViewGroup group){
// for(int i = 0 ;i< group.getChildCount();i++)
// group.getChildAt(i).setPressed(true);
for(int i = 0 ; i < group.getTouchables().size();i++){
group.getTouchables().get(i).setOnTouchListener(new AlphaListener());
}
}
public static void setChildsOnClickListener(ViewGroup group,OnClickListener listener){
// for(int i = 0 ;i< group.getChildCount();i++)
// group.getChildAt(i).setPressed(true);
for(int i = 0 ; i < group.getTouchables().size();i++){
group.getTouchables().get(i).setOnClickListener(listener);
}
}
public static void backgroundProcess(Context context,final Runnable run){
backgroundProcess(context, run,null);
}
public static void backgroundProcess(Context context,final Runnable run,String loadingComment){
final ProgressDialog progressdialog = KGlobal.creativeProgressBar(context,loadingComment);
progressdialog.show();
Runnable wrapper =new Runnable() {
public void run() {
run.run();
progressdialog.dismiss();
}
};
Thread thread = new Thread(wrapper);
thread.setDaemon(true);
thread.start();
}
public static void setAnimation(Context context,ViewAnimator victim,int in_animRrs,int out_animRrs) {
// victim.setInAnimation(AnimationUtils.loadAnimation(context, animRrs));
victim.setInAnimation(context, in_animRrs);
victim.setOutAnimation(context, out_animRrs);
}
public static void goMarket(Context context,String pkgname){
// Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.zxing.client.android"));
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+pkgname));
context.startActivity(marketIntent);
}
public static int getViewWidth(View context){
return context.getMeasuredWidth();
}
public static int getViewHeight(View context){
return context.getMeasuredHeight();
}
public static int getWindowWidth(Activity context){
Display display = ((WindowManager) context.getApplicationContext().getSystemService(context.getApplicationContext().WINDOW_SERVICE)).getDefaultDisplay();
return display.getWidth();
}
public static int getWindowHeight(Activity context){
Display display = ((WindowManager) context.getApplicationContext().getSystemService(context.getApplicationContext().WINDOW_SERVICE)).getDefaultDisplay();
return display.getHeight();
}
public static LinearLayout makeMeasRow(Context context,KCustomMeasStd_DTO atdata){
return makeMeasRow(context,atdata,null);
}
public static LinearLayout makeMeasRow(Context context,KCustomMeasStd_DTO atdata,ArrayList<String> additem){
LinearLayout layout =null;
TextView title = null;
LinearLayout value = null;
LinearLayout.LayoutParams param =null;
layout = (LinearLayout)KGlobal.creativeLayout(context, R.layout.meas_freesize_row_container);
title = KGlobal.creativeTextView(context, atdata.getITEMNAME(),18,0xFFc8c8c8);
((ViewGroup)layout.findViewById(R.id.title_container)).addView(title);
param = (android.widget.LinearLayout.LayoutParams) title.getLayoutParams();
param.weight=ViewGroup.LayoutParams.WRAP_CONTENT;
param.height=ViewGroup.LayoutParams.FILL_PARENT;
title.setLayoutParams(param);
value = (LinearLayout)KGlobal.creativeLayout(context, R.layout.meas_value);
((TextView)value.findViewById(R.id.value)).setText(atdata.getVALUE());
((TextView)value.findViewById(R.id.value)).setTextSize(30);
if(atdata.getSTATUS()>=0)
((TextView)value.findViewById(R.id.value)).setTextColor(KM2MUtil.getColor(atdata.getSTATUS()));
if(atdata.getSIGN()==null || atdata.getSIGN().equals(""))
((TextView)value.findViewById(R.id.sign)).setVisibility(View.GONE);
else
((TextView)value.findViewById(R.id.sign)).setText(atdata.getSIGN());
((ViewGroup)layout.findViewById(R.id.value_container)).addView(value);
if(additem!=null){
for(int i = 0 ; i < additem.size();i++){
TextView bottomValue = KGlobal.creativeTextView(context, additem.get(i));
((ViewGroup)layout.findViewById(R.id.value_container)).addView(bottomValue);
setChild_LinearLayoutparam(((LinearLayout)layout.findViewById(R.id.value_container)), ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
}
}
return layout;
}
public static void addMeasRows(Context context,ViewGroup container,ArrayList<KCustomMeasStd_DTO> meas){
addMeasRows(context, container, meas, false);
}
public static void addMeasRows(Context context,ViewGroup container,ArrayList<KCustomMeasStd_DTO> meas,boolean want_append){
if(!want_append)
container.removeAllViews();
for(int i = 0 ; i <meas.size();i++){
LinearLayout layout = makeMeasRow(context,meas.get(i));
container.addView(layout);
KGlobal.setParent_LinearLayoutparam(layout,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT,1);
}
}
public static ArrayList<KCustomMeasStd_DTO> getChart(
String startymd,int jump,String itemname,String columnname,String sign,
int wantsize,int standardValue , int toleranceValue,boolean wantTime ){
ArrayList<KCustomMeasStd_DTO> returnvalue = new ArrayList<KCustomMeasStd_DTO>();
double[] randomvalue= Utilities.getRandom(standardValue, toleranceValue, wantsize);
for(int i=0;i<wantsize;i++){
KCustomMeasStd_DTO item= new KCustomMeasStd_DTO();
if(wantTime){
item.setRECVDATE(startymd);
item.setRECVTIME(String.format("%02d0000", i+jump));
}else{
int[] ymd_int = Utilities.formatDate_toIntArray(startymd);
String ymd=Utilities.setDate_toString(ymd_int[0],ymd_int[1],ymd_int[2],0,0,-(i+jump));
item.setRECVDATE(ymd);
item.setRECVTIME(String.format("%02d0000", 12));
}
item.setITEMNAME(itemname);
item.setITEMNAME(itemname);
item.setCOLUMNNAME(columnname);
item.setSIGN(sign);
item.setCURR_VALUE(randomvalue[i]);
item.setVALUE(Utilities.stringCasting(item.getCURR_VALUE(), 0, 1));
returnvalue.add(item);
}
return returnvalue;
}
내꺼입니다.ㅎ가따스세요 ㅋ




데이터만 정렬해서 보여주면 대는거 아닌가여?ㅋ
웹서버 db데이터를 xml 화 해서 안드로이드 프로젝트에서 파싱한 후에
소팅해서 보여 주면 댈거 같은데....