これは私の主なレイアウトです:
<RelativeLayout style="@style/StandardFillWrap" >
<TableLayout
android:id="@+id/match_tab"
style="@style/StandardFillWrap"
android:stretchColumns="*" >
<TableRow >
<TextView android:id="@+id/match_home_name" />
<TextView android:id="@+id/match_home_score" />
</TableRow>
<TableRow >
<TextView android:id="@+id/match_away_name" />
<TextView android:id="@+id/match_away_score" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/match_filter_b"
style="@style/StandardFillWrap"
android:layout_below="@id/match_tab"
android:text="@string/l_matchView_filters" />
<LinearLayout android:id="@+id/match_list"
style="@style/StandardWrapWrap"
android:layout_below="@id/match_filter_b"
/>
<TableLayout
android:id="@+id/match_reparti"
style="@style/StandardFillWrap"
android:layout_below="@id/match_list"
android:stretchColumns="*" >
<TableRow >
<TextView
android:id="@+id/match_home_name_det"
style="@style/NomePlayer"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_indirect_set_pieces" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_defence" />
<TextView android:id="@+id/match_home_set_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_attack" />
<TextView android:id="@+id/match_home_set_att" />
</TableRow>
<TableRow >
<TextView android:text="@string/vuoto" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_team_attitude" />
<TextView android:id="@+id/match_home_team_attitude" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_tactic" />
<TextView android:id="@+id/match_home_team_tactic" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_tactic_skill" />
<TextView android:id="@+id/match_home_team_tactic_skill" />
</TableRow>
<TableRow >
<TextView android:text="@string/vuoto" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_midfield" />
<TextView android:id="@+id/match_home_team_midfield" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_right_defence" />
<TextView android:id="@+id/match_home_team_r_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_central_defence" />
<TextView android:id="@+id/match_home_team_c_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_left_defence" />
<TextView android:id="@+id/match_home_team_l_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_right_attack" />
<TextView android:id="@+id/match_home_team_r_att" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_central_attack" />
<TextView android:id="@+id/match_home_team_c_att" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_left_attack" />
<TextView android:id="@+id/match_home_team_l_att" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/match_away_name_det"
style="@style/NomePlayer"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_indirect_set_pieces" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_defence" />
<TextView android:id="@+id/match_away_set_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_attack" />
<TextView android:id="@+id/match_away_set_att" />
</TableRow>
<TableRow >
<TextView android:text="@string/vuoto" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_team_attitude" />
<TextView android:id="@+id/match_away_team_attitude" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_tactic" />
<TextView android:id="@+id/match_away_team_tactic" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_tactic_skill" />
<TextView android:id="@+id/match_away_team_tactic_skill" />
</TableRow>
<TableRow >
<TextView android:text="@string/vuoto" />
<TextView android:text="@string/vuoto" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_midfield" />
<TextView android:id="@+id/match_away_team_midfield" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_right_defence" />
<TextView android:id="@+id/match_away_team_r_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_central_defence" />
<TextView android:id="@+id/match_away_team_c_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_left_defence" />
<TextView android:id="@+id/match_away_team_l_def" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_right_attack" />
<TextView android:id="@+id/match_away_team_r_att" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_central_attack" />
<TextView android:id="@+id/match_away_team_c_att" />
</TableRow>
<TableRow >
<TextView android:text="@string/l_matchView_left_attack" />
<TextView android:id="@+id/match_away_team_l_att" />
</TableRow>
</TableLayout>
</RelativeLayout>
そして、埋める方法match_list
は次のとおりです。
private void mimicListAdapter(List<Event> eventsList, String filters) {
TextView minute;
ImageView event_key;
TextView event_text;
LayoutInflater inflater = getLayoutInflater();
LinearLayout container = (LinearLayout) findViewById(R.id.match_list);
for(Event p:eventsList) {
//LayoutInflater inflater = getLayoutInflater();
View rowView = inflater.inflate( R.layout.match_event, null, true);
minute = (TextView) rowView.findViewById(R.id.minute);
event_key = (ImageView) rowView.findViewById(R.id.event_img);
event_text = (TextView) rowView.findViewById(R.id.event_text);
boolean found = false;
String[] events = getResources().getStringArray(R.array.filtering);
if(filters!=null)
{
if(filters!="")
{
char[] indici = filters.toCharArray();
for(int i = 0; i<indici.length; i++){
if(events[Character.getNumericValue( indici[i] )].contains(","+p.getEventKey()+","))
{
found=true;
break;
}
}
}
}
minute.setText(Integer.toString(p.getMinute()));
event_text.setText(p.getEventText());
try {
Drawable img = getResources().getDrawable( getResources().getIdentifier("i_"+p.getEventKey(), "drawable", getPackageName()));
event_key.setImageDrawable(img);
} catch (Exception e) {
}
if(found) {
event_text.setTextColor(0xFFFF0000);
minute.setTextColor(0xFFFF0000);
found = false;
}
container.addView(rowView);
}
}
私が抱えている問題は、外側にあるものはすべてmatch_list
正しく表示され、match_list の内側には最初の要素が表示されますが、すべて空白です。つまり、LinearLayout はディスプレイの大部分を占めているため、いっぱいになっているEvent
ように見えますが、最初に表示されるのは単なる黒いスペースです。