在我的Android应用程序中,我必须在相应的类别上显示文章标题。
我希望以下列格式显示输出:
Languages Programming --- Category name on Horizontal listview
如果我必须点击语言,这意味着单独获取所选类别的文章标题并显示在水平列表视图上。
Languages Programming
Tamil Engilsh Hindi Telugu
如果我必须点击编程表示需要显示:
Languages Programming
Java C C++
现在我的当前状态是:
我必须运行该应用并点击语言,这意味着获得输出:
Languages Programming
Tamil English Hindi
之后我必须单击编程意味着获得输出:
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++