안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요 초보 개발자 입니다..
메인 화면 입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
</RelativeLayout>
<FrameLayout
android:id="@+id/fLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
layout="@layout/mainlayout"
android:id="@+id/mainInclude"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
main.xml 구성을 하였습니다.
상단 버튼을 클릭 하여
메인 프레임에 있는 버튼의 이미지를 변경할수는 있는데요
반대로 메인 프레임에서 상단의 버튼의 이미지는 변경할수가 없네요..
메인 소스는
public class test extends Activity implements View.OnClickListener
{
TestClass tclass;
LinearLayout layoutMapView;
LinearLayout mainLayout;
ImageButton ibtnZoomIn;
ImageButton ibtnZoomOut;
ImageButton ibtnInfo;
ImageButton ibtn_4;
ImageButton ibtn_5;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
tclass = new TestClass(this);
mainLayout = (LinearLayout) findViewById(R.id.mainInclude);
mainLayout.setOnClickListener(this);
ibtna = (ImageButton)findViewById(R.id.a);
ibtna.setOnClickListener(this);
ibtnb = (ImageButton)findViewById(R.id.b);
ibtnb.setOnClickListener(this);
ibtnc = (ImageButton)findViewById(R.id.c);
ibtnc.setOnClickListener(this);
ibtn_4 = (ImageButton)findViewById(R.id.ibtn_4);
ibtn_4.setOnClickListener(this);
ibtn_5 = (ImageButton)findViewById(R.id.ibtn_5);
ibtn_5.setOnClickListener(this);
}
public void onClick( View v )
{
switch(v.getId())
{
....
}
}
}
메임 프레임의 설정은
TestClass 에 있습니다.
메인 화면 입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
<ImageButton
android:background="@drawable/a"
android:layout_height="120px"
android:layout_width="120px">
</ImageButton>
</RelativeLayout>
<FrameLayout
android:id="@+id/fLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
layout="@layout/mainlayout"
android:id="@+id/mainInclude"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
main.xml 구성을 하였습니다.
상단 버튼을 클릭 하여
메인 프레임에 있는 버튼의 이미지를 변경할수는 있는데요
반대로 메인 프레임에서 상단의 버튼의 이미지는 변경할수가 없네요..
메인 소스는
public class test extends Activity implements View.OnClickListener
{
TestClass tclass;
LinearLayout layoutMapView;
LinearLayout mainLayout;
ImageButton ibtnZoomIn;
ImageButton ibtnZoomOut;
ImageButton ibtnInfo;
ImageButton ibtn_4;
ImageButton ibtn_5;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
tclass = new TestClass(this);
mainLayout = (LinearLayout) findViewById(R.id.mainInclude);
mainLayout.setOnClickListener(this);
ibtna = (ImageButton)findViewById(R.id.a);
ibtna.setOnClickListener(this);
ibtnb = (ImageButton)findViewById(R.id.b);
ibtnb.setOnClickListener(this);
ibtnc = (ImageButton)findViewById(R.id.c);
ibtnc.setOnClickListener(this);
ibtn_4 = (ImageButton)findViewById(R.id.ibtn_4);
ibtn_4.setOnClickListener(this);
ibtn_5 = (ImageButton)findViewById(R.id.ibtn_5);
ibtn_5.setOnClickListener(this);
}
public void onClick( View v )
{
switch(v.getId())
{
....
}
}
}
메임 프레임의 설정은
TestClass 에 있습니다.
2011.02.11 16:10:41
예 뷰를 상속 받은 클래스인 TestClass에 버튼 이벤트를 줬는데요...
버튼을 클릭 할경우.. 상위단에 버튼에 이미지를 변경하려고 하는데..
this를 써도 super 를 써도 안되네요..
버튼을 클릭 할경우.. 상위단에 버튼에 이미지를 변경하려고 하는데..
this를 써도 super 를 써도 안되네요..
2011.02.15 16:29:49
프레임 레이아웃 안에 집어넣으신 부분 <include
layout="@layout/mainlayout"
android:id="@+id/mainInclude"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
여기에 버튼이 들어가 있는것 같은데 이부분 자바는 어떻게 짜신건가요? 보통 레이아웃을 상속받은 클레스에 LayoutInflater inflater로 뷰를 연결하고 버튼 이벤트도 주는데.. 그부분이 안보이는군요 ;



