안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요 초보 개발자 입니다..
TestView tView;
tView = new TestView(this);
layoutView1 = (LinearLayout)findViewById(R.id.mainlayout1);
layoutView1.addView(tView);
layoutView2 = (LinearLayout)findViewById(R.id.mainlayout2);
layoutView2.addView(tView);
public class TestView extends View
{
public TestView (Context context)
{
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
}
}
두곳에 tView를 넣고 싶은데.. 에러가 발생하네요..
어떻게 하면 두곳에 다 사용할수 있도록 도와주세요~~~
TestView tView;
tView = new TestView(this);
layoutView1 = (LinearLayout)findViewById(R.id.mainlayout1);
layoutView1.addView(tView);
layoutView2 = (LinearLayout)findViewById(R.id.mainlayout2);
layoutView2.addView(tView);
public class TestView extends View
{
public TestView (Context context)
{
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
}
}
두곳에 tView를 넣고 싶은데.. 에러가 발생하네요..
어떻게 하면 두곳에 다 사용할수 있도록 도와주세요~~~




LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
tView = inflater.inflate(int layout_resource, ViewGroup root);