나는 같은 레이아웃을 여러 번 rood layout.Now에서 다음과 같이 중첩 된 레이아웃으로보기에 액세스하고 있습니다. 오랜 시간이 걸릴 것입니다. 더 나은 해결책이 있습니까?Android : 중첩 된 레이아웃의보기에 액세스하는 데 시간이 필요합니까?
TextView tv=(TextView)findViewById(R.id.fragment_forcast).findViewById(R.id.horizontalScrollView).
findViewById(R.id.liner_layout).findViewById(R.id.forcas_layout_1).findViewById(R.id.day_field)
업데이트 :
private void populateForcastView(){
TextView tv;
View rootView=(View)findViewById(R.id.fragment_forcast).findViewById(R.id.horizontalScrollView).
findViewById(R.id.liner_layout);
for(int forcastFragmentIndex=1; forcastFragmentIndex<=3; forcastFragmentIndex++){
int forcastFragmentId=getResources().getIdentifier("forcast_layout_" + forcastFragmentIndex, "id", getPackageName());
tv=(TextView)rootView.findViewById(forcastFragmentId).findViewById(R.id.day_field);
tv.setText("Sunday");
}
}
지금 받으십시오. 대답에 올바른 접근 방식을 게시했습니다. –