package com.example.menu_ex1;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.ImageView;
public class Menu_ex1Activity extends Activity {
EditText edtAngle;
ImageView imageView1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setTitle("제주도 풍경");
edtAngle = (EditText) findViewById(R.id.edtAngle);
imageView1 = (ImageView) findViewById(R.id.imageView1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
super.onCreateOptionsMenu(menu);
MenuInflater mInflater = getMenuInflater();
getMenuInflater().inflate(R.menu.menu_ex1, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.itemRotate:
imageView1.setRotation(Float.parseFloat(edtAngle.getText().toString()));
return true;
case R.id.item1:
imageView1.setImageResource(R.drawable.jeju02);
return true;
case R.id.item2:
imageView1.setImageResource(R.drawable.jeju03);
return true;
case R.id.item3:
imageView1.setImageResource(R.drawable.jeju04);
return true;
}
return false;
}
}
이건 자바 쪽이구요
xml 은
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/baseLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/jeju02"
/>
<EditText
android:id="@+id/edtAngle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/textView1"
android:inputType="textNoSuggestions"
android:text="0" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentLeft="true"
android:text="각도 입력"
android:textSize="20dp"
/>
</RelativeLayout>
메뉴 쪽은
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/itemRotate"
android:title="그림 회전"/>
<group
android:checkableBehavior="single" >
<item
android:id="@+id/item1"
android:checked="true"
android:title="한라산">
</item>
<item
android:id="@+id/item2"
android:title="추자도" >
</item>
<item
android:id="@+id/item3"
android:title="범섬">
</item>
</group>
</menu>
이렇게 되어있는데
여기서 옵션메뉴에 라디오버튼식으로 되있어서 한라산 누르면 한라산이 체크되어있고
범섬 누르면 범섬쪽 라디오 버튼이 추자도 누르면 추자도 라디오 버튼이 눌려야되는데
계속 한라산만 체크되어있네요 이미지를 바꾸면..
어떻게 해야되나요?
그리고 이미지를 한라산을 회전시키면 추자도 범섬 이미지까지 다 회전되어져있네요 ㅠㅠ