package com.corea;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
public class Image_ViewActivity extends Activity implements OnClickListener, OnSeekBarChangeListener {
protected static final int PICK_FROM_ALBUM = 0;
/** Called when the activity is first created. */
Button btn,btn2;
ImageView image;
SeekBar sek;
TextView txt;
Uri mImageUri;
RadioGroup radiogroup;
int CHECKED_ARGB =1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txt = new TextView(this);
txt = (TextView)findViewById(R.id.test);
sek = new SeekBar(this);
sek = (SeekBar)findViewById(R.id.seekBar1);
sek.setOnSeekBarChangeListener(this);
// onProgressChanged(sek, 100, true);
sek.setMax(255);
image=(ImageView)findViewById(R.id.imageView1);
radiogroup = new RadioGroup(this);
radiogroup = (RadioGroup)findViewById(R.id.radioGroup1);
radiogroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
// TODO Auto-generated method stub
switch(arg1)
{
case R.id.rad4:
CHECKED_ARGB = 1;
break;
case R.id.rad1:
CHECKED_ARGB = 2;
break;
case R.id.rad2:
CHECKED_ARGB = 3;
break;
case R.id.rad3:
CHECKED_ARGB = 4;
break;
}
}
});
btn = new Button(this);
btn = (Button)findViewById(R.id.button1);
btn2 = new Button(this);
btn2 = (Button)findViewById(R.id.button2);
btn.setOnClickListener(this);
btn2.setOnClickListener(this);
image.setOnLongClickListener(new OnLongClickListener()
{
@Override
public boolean onLongClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(android.provider.MediaStore.Images.Media.CONTENT_TYPE);
startActivityForResult(intent, PICK_FROM_ALBUM);
return false;
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data )
{
if (resultCode ==RESULT_OK)
{
if(requestCode == PICK_FROM_ALBUM)
{
mImageUri = data.getData();
image.setImageURI(mImageUri);
}
}
}
public void onClick(View v)
{
if(v==btn)
{
image.setImageResource(R.drawable.test2);
}else
{
image.setAlpha(50);
}
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
final int alphaVal = progress;
image.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
switch(CHECKED_ARGB){
case 1:
image.setAlpha(255-alphaVal);
txt.setText(""+alphaVal);
break;
case 2:
image.setAlpha(alphaVal);
txt.setText(""+alphaVal);
break;
case 3:
image.setAlpha(alphaVal);
txt.setText(""+alphaVal);
break;
case 4:
image.setAlpha(alphaVal);
txt.setText(""+alphaVal);
break;
}
}
});
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
}
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)