[Android] AlertDialog

Android 2012. 6. 15. 13:28

Dialog 메시지를 HTML


        AlertDialog.Builder ab = null;

                ab = new AlertDialog.Builder( HelloAndroid2Activity.this );

                ab.setMessage( Html.fromHtml("<b><font color=#ff00ff> HTML View</font></b><br>Android.com"));

                ab.setPositiveButton(android.R.string.oknull);

                ab.setTitle( "Basic Alert Dialog" );

                 ab.show();




OK/Cancel Dialog


AlertDialog.Builder closeConfirm = new AlertDialog.Builder(xxxActivity.this);

closeConfirm.setTitle(title);

closeConfirm.setMessage(msg );

closeConfirm.setNegativeButton("OK",

                                      new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int which) {

           

          }

    });

    closeConfirm.setPositiveButton("cancel",

                                      new DialogInterface.OnClickListener() {

    public void onClick(DialogInterface dialog, int which) {

              return;

    }

    });

    closeConfirm.show();





HTML 사용시 개행


confirm.setMessage("ブラウザで開きます。"+"\n"+"よろしいですか。");





배경을 눌러 다이어로그가 사라지는 것을 방지하려면



closeConfirm.setCancelable(false); // 취소불가







< 참조 URL >

http://utime.blog.me/150091024547



Posted by tenn
,

[Android] Button

Android 2012. 6. 15. 13:22





버튼 기본 조작 / 버튼 클릭시 타이틀 바꾸기


import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.view.View.OnClickListener;


public class HelloAndroid2Activity extends Activity {

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

    

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        

        Button btn1 = (Button)findViewById(R.id.button1);

        

        btn1.setOnClickListener(

             new OnClickListener(){

                 public void onClick(View v){

                     if(((Button)v).getText().equals("clicked!")){

                         ((Button)v).setText("Button");

                     }else{

                        ((Button)v).setText("clicked!");

                     }

                }

            }

        );

        

    }

}







Posted by tenn
,

[objc] UIButton

iPhone 2012. 6. 14. 15:25



버튼 코드 생성


    self.startTimeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    [self.startTimeBtn setTitle:@"start time" forState:UIControlStateNormal];

    self.startTimeBtn.frame = CGRectMake(505011040);



버튼 영역이 모자라면 자동줄바꿈



   //btn : UIButton 

   [self.btn.titleLabel setLineBreakMode:UILineBreakModeWordWrap];


이벤트 핸들링



    [self.startTimeBtn addTarget:self  

                          action:@selector(startTimeBtnAction:)forControlEvents:UIControlEventTouchUpInside];



- (IBAction)startTimeBtnAction:(id)sender {

...

}




title text


[yourButton setTitle:@"your title" forState:UIControlStateNormal];

[yourButton setTitle:@"your title" forState:UIControlStateSelected];

[yourButton setTitle:@"your title" forState:UIControlStateHighlighted];







Button Image 바꾸기


[btn setBackgroundImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];


//[btn setBackgroundImage:image forState:UIControlStateNormal];

//[btn setBackgroundImage:image forState:UIControlStateHighlighted];

// Hightlight없으면 적용이 안됨??? <- 미확인


Posted by tenn
,