在我的 Android 应用程序中,我必须在相应类别中显示文章标题。
我希望以以下格式显示输出:
Languages Programming --- Category name on Horizontal listview
如果我必须单击语言,这意味着单独获取该选定类别的文章标题并显示在水平列表视图上。
Languages Programming
Tamil Engilsh Hindi Telugu
如果我必须单击编程意味着需要显示:
Languages Programming
Java C C++
现在我目前的状态是:
我必须运行应用程序并单击语言,这意味着获取输出是:
Languages Programming
Tamil English Hindi
之后,我必须单击 Programming 意味着得到输出是:
Languages Programming
Tamil English Hindi
我的代码有什么问题?为什么在我的应用程序屏幕上得到相同的输出?但是我在控制台窗口上得到了正确的文章标题。我只在我的应用程序屏幕上遇到问题..
我的代码有什么问题...请给我解决方案...
public void updateDetail(String categorytitle,int object) {
lblName.setText(categorytitle);
System.out.println("The Category name is "+categorytitle);
String strI = Integer.toString(object+1);
String[] stockArr = new String[Appscontent.Sub_arraylist.size()];
stockArr = Appscontent.Sub_arraylist.toArray(stockArr);
for (String s : stockArr)
{
if (s.startsWith(strI))
{
String _Substring;
_Substring = s.substring(1);
Appscontent.Sub_arraylisttwo.add(_Substring);
}
}
//pass the article title
hSroll = new HorizontalScrollView(getActivity());
lLayout = new LinearLayout(getActivity());
lLayout.setOrientation(LinearLayout.HORIZONTAL);
lLayout.setLayoutParams(lLayoutLayoutParams);
lLayout.setHorizontalScrollBarEnabled(true);
lLayout.setGravity(Gravity.CENTER);
for(int j = 0; j < Appscontent.Sub_arraylisttwo.size(); j++)
{
LinearLayout ly = new LinearLayout(getActivity());
ly.setOrientation(LinearLayout.VERTICAL);
ly.setBackgroundColor(Color.parseColor("#666666"));
ly.setLayoutParams(articleLayoutParams);
ly.setPadding(1, 1, 1, 1);
ly.setOnClickListener(mArticleClick);
ly.setId(position);
position++;
TextView tv = new TextView(getActivity());
tv.setHorizontallyScrolling(false);
tv.setTextColor(Color.parseColor("#FFFFFF"));
tv.setText(Appscontent.Sub_arraylisttwo.get(j));
System.out.println("The article title is "+Appscontent.Sub_arraylisttwo.get(j));
ly.addView(tv);
lLayout.addView(ly);
}
int num = Integer.parseInt(strI);
strI = String.valueOf(num = num + 1);
Appscontent.Sub_arraylisttwo.clear();
Appscontent.Sub_arraylistdessub.clear();
Appscontent.Sub_arraylistimagesub.clear();
Appscontent.Sub_arraylistcontentsub.clear();
Appscontent.Sub_arraylistvideosub.clear();
hSroll.addView(lLayout);
verticalLayout.addView(hSroll);
}
请查看我的代码并为我提供解决方案...在我的控制台窗口上获得正确的输出。但我没有在我的 android 应用程序屏幕上获得输出...
编辑:
我的 consolw 输出是:
当点击语言意味着
The Category name is Languages
The article title is Tamil
The article title is English
The article title is Hindi
The article title is Telugu
之后我点击了编程手段
The Category name is Programming
The article title is Java
The article title is c
The article title is C++