フラグメント内のテーブル レイアウトにいくつかのボタンをロードしようとしています。なぜこれが表示されないのでしょうか。背景の変更が機能することがわかります(onCreateView(......)で灰色から赤に変更されました)が、loadAllButtonsを呼び出すと表示されません。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if(container == null)
return null;
basedView = (TableLayout) inflater.inflate(R.layout.fragment_difficult_sound_syllable, container, false);
currentSyllable = getArguments().getString(StaticValues.DIFFICULT_SOUND_SELECTOR);
basedView.setBackgroundColor(Color.RED);
return basedView;
}
以下は私のloadAllButtonsであり、誰かが「はい」と尋ねる前に、すべてがロードされていると言います(たとえば、ボタンと行が追加され、row.add()とbasedView.add()の後にlogcatを介してチェックされます)
private void loadAllButtons()
{
DataBaseHelper tmpHelper = new DataBaseHelper(getActivity().getApplicationContext());
ArrayList<ButtonInfoContainer> tmpArray = null;
if(currentSyllable.contentEquals(StaticValues.CONSONANT))
{
tmpArray = tmpHelper.returnAllConsonants();
Log.i(StaticValues.TAG, "returned all consonants");
}
else
{
tmpArray = tmpHelper.returnAllVowels();
Log.i(StaticValues.TAG, "returned all vowels");
}
if(tmpArray != null)
{
TableRow row = null;
InfoButton tmpButton = null;
//LayoutParams rowParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//TableRow.LayoutParams equalParams = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0);
LinearLayout.LayoutParams buttonLayout = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
if(basedView != null)
{
for(int i = 0; i < tmpArray.size(); i++)
{
//adds new row to table if modulus is 0
if(( i % 2 ) == 0)
{
row = (TableRow) getLayoutInflater(getArguments()).inflate(R.layout.table_row, null);
//row.setLayoutParams(rowParams);
basedView.addView(row);
}
tmpButton = (InfoButton) getLayoutInflater(getArguments()).inflate(R.layout.info_button, null);
tmpButton.setBackgroundResource(R.drawable.button_bg);
tmpButton.setLayoutParams(buttonLayout);
//set button Text
tmpButton.setText(tmpArray.get(i).buttonText);
//Obtain extra held info
tmpButton.setExtraInfo(tmpArray.get(i).infoHeld);
//tmpButton.setWidth(buttonWidth);
//tmpButton.setHeight(buttonHeight);
//tmpButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
tmpButton.setTextColor(getResources().getColor(R.color.button_text_color));
tmpButton.setTypeface(Typeface.DEFAULT_BOLD);
row.addView(tmpButton);
tmpButton.setOnClickListener(listenerDynamicButton);
}
}
}
}
何らかの理由で、logcat の出力がすべて正常であることを示していても (適切な名前の適切な数のボタンを示すボタン)、それらのテーブル レイアウトは取り込まれません。