내 응용 프로그램에서 scrollview를 사용하고 싶습니다. scrollview에 텍스트보기를 추가하려고 시도했지만 스크롤보기의 배경색을 제외하고 렌더링 된 것을 볼 수 없습니다. 여기Android scrollview는 프로그래밍 방식으로 생성 할 수 없습니다.
내가 그것을 어떻게 있습니다 :
public class MyView extends ViewGroup
{
ScrollView myScrollview;
Textview tv;
public MyView(Context context) {
myScrollView = new ScrollView(context);
myScrollView.setBackgroundColor(0xfff00fff);
textview=new TextView(context);
textview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
textview.setLayoutParams(params)
textview.setText("sadfasdfasdfasdfasdfasdfasdfsadfsadf");
textview.layout(0, 0, 1000, 2000);
textview.setHeight(5000);
textview.setWidth(3200);
myScrollView .addView(tv);
addView(myScrollview);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
int width = r-l;
int height =b-t;
myScrollView .layout(0, 0, width, height-100);
}
}
내가 거의 모든있는 ScrollView 튜토리얼 뷰를 정의하기 위해 XML을 사용하는 발견했다. 하지만 프로그래밍 방식으로하고 싶습니다. 그러나 어쨌든, 나는 또한 xml을 시도했다. , 그 자체로는 XML있는 ScrollView가 올바른지
//www.curious-creature.org/2010/08/15/scrollviews-handy-trick/ : HTTP :
내가 테스트를 위해 여기에서 로맹 가이의 XML을 복사 이 스크롤 뷰를 작성하여 액티비티에 추가하면,
scrollview= (ScrollView) getLayoutInflater().inflate(R.layout.scrollviewid,null);
setContentView (scrollview);
또는 setContentView(R.layout.scrollviewid);
일했다. 그러나 scrollview를 다른보기의 하위보기로 만들고 싶다면 다시 scrollview의 배경 만 볼 수 있습니다. 내부는 렌더링되지 않습니다.
public class MyView extends ViewGroup
{
ScrollView myScrollview;
public MyView(Activity activity,Context context)
{
super(context);
myScrollview= (ScrollView) activity.getLayoutInflater().inflate(R.layout.restaurantcategoryselectorviewlayout,null);
myScrollview.setBackgroundColor(0xfff00fff);
addView(myScrollview);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
int width = r-l;
int height =b-t;
myScrollview.layout(0, 0, width, height-100);
}
}
내 코드에 어떤 문제가 있습니까? xml이 아닌 프로그램으로 scrollview를 만드는 예가 있습니까?
또한 kernel.org에서도 android의 자바 소스 코드입니까? 자식 서비스가 다운 되었기 때문에, 어디에서 안드로이드 소스 코드를 다운로드 할 수 있습니까?