안녕하세요^^ 안드로이드를 최근에 공부하고있는데요...


질문이 있습니다~ 


지금 화면상에 버튼 a, b, c, d가 있구요, 버튼을 누를때마다 보여주는 레이아웃 A, B, C, D가 있습니다.


이것을 클래스A에서 모두 적었는데요,


잘~됩니다... 전혀 문제는 없습니다. 여기서 onClickListener는 클래스A에 두고, 클래스A에서 클래스B의 메소드를 호출해서

클래스B의 메소드에서 레아이웃을 보여주고, 숨기는 기능을 하고싶은데요... 잘 안되내요;;


이렇게 되면... 클릭됬을때 실행되는것은 클래스B, 기본 틀은 클래스A에 코드를 작성하고 싶거든요...


자바에서는 그냥 호출하면되는데, 이거는 View가 넘어오고 그런 개념이다보니...잘안되내요;;


아, 그리고 클래스B에서는 클래스A를 상속도 시켜봤는데 안되더군요... ㅠ

 

혹시 몰라, 소스코드 첨부하였습니다.

 

아래는 클래스A 에서 버튼에 대한 OnClickListener() 입니다.

       MenuClick MC = new MenuClick();
      String strTag = v.getTag().toString();
      
      MC.setMenu(strTag);

아래는 클래스B에 작성한 코드입니다.

import android.view.View;
import android.widget.LinearLayout;
public class MenuClick extends ProjectActivity {
 public void setMenu(String strTag) {
  LinearLayout[] Layouts = new LinearLayout[7];
  Layouts[0] = (LinearLayout) findViewById(R.id.lLayoutMain);
  Layouts[1] = (LinearLayout) findViewById(R.id.lLayoutCall);
  Layouts[2] = (LinearLayout) findViewById(R.id.lLayoutSchedule);
  Layouts[3] = (LinearLayout) findViewById(R.id.lLayoutState);
  Layouts[4] = (LinearLayout) findViewById(R.id.lLayoutCaution);
  Layouts[5] = (LinearLayout) findViewById(R.id.lLayoutMessage);
  Layouts[6] = (LinearLayout) findViewById(R.id.lLayoutSetup);
  
  int i;
  for (i=0;i<7;i++) {
   Layouts[i].setVisibility(View.GONE);
  }
  
  if (strTag.equals("call")) {
   Layouts[1].setVisibility(View.VISIBLE);
  }
  else if (strTag.equals("schedule")) {
   Layouts[2].setVisibility(View.VISIBLE);
  }
  else if (strTag.equals("state")) {
   Layouts[3].setVisibility(View.VISIBLE);
  }
  else if (strTag.equals("caution")) {
   Layouts[4].setVisibility(View.VISIBLE);
  }
  else if (strTag.equals("message")) {
   Layouts[5].setVisibility(View.VISIBLE);
  }
  else if (strTag.equals("setup")) {
   Layouts[6].setVisibility(View.VISIBLE);
  }
 }
}