안녕하세요, 저는이 Android에 매우 익숙합니다. 실제로 저는 스크린 아래에 1 개의 제목과 설명을 표시하려고합니다. Galleryview를 사용하여이 작업을 수행했습니다. 이것이 올바른 방법인지는 모르겠다. 이건 아니야 ..갤러리 뷰 in android
내 생각은 .. 내가 화면을 스 와이프하면 (제목과 설명이 와야 함)하지만이 일은 할 수 없다. 나는 다음과 이전 옵션을 유지하려고 시도했다. 이 일을하기 위해서 ..하지만이 또한 할 수 없습니다 .. 나는 잘못된 길을 가고 있음을 알고 있습니다.이 일을 할 수있는 좋은 길을 제안 해주세요 .. 필요하다면 더 많은 설명을 드릴 준비가되었습니다. 아래의 코드는 무엇입니까? 완료 ...
내 활동 코드 :
public class NewsDescription extends Activity
{
// private String url = "http://m.indiatoday.in/xml/stories/"+(String)context.getInstance().getAppVariable("storyurl");
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.newsdesgallery);
Gallery gl=(Gallery)findViewById(R.id.GalleryNewsDesc);
NewsDescriptionAdapter adapter =new NewsDescriptionAdapter(this);
gl.setAdapter(adapter);
}
}
내 어댑터 클래스 : 그것은 는 안드로이드의 최신 버전에 사용되지 같이
public class NewsDescriptionAdapter extends BaseAdapter
{
private static Context contxt;
String[] body= {};//new String[30];
String[] heading= {};//new String[30];
NewsDescriptionAdapter(Context conxt)
{
// System.out.println("inside cons");
this.contxt=conxt;
getelement();
}
public void getelement()
{
// System.out.println("Inside getElement");
String[] url=context.getInstance().getselectedUrl();
// System.out.println("After url");
// System.out.println("count="+(String)context.getInstance().getAppVariable("count"));
int count = Integer.parseInt((String)context.getInstance().getAppVariable("count"));
// System.out.println("count="+count);
// System.out.println("after count="+url[count]);
String URL = "http://xxxx.in/xml/stories/"+url[count];
// System.out.println("url="+URL);
TaplistingParser parser = new TaplistingParser();
// try {
// url=URLEncoder.encode(url, "UTF-8");
// } catch (UnsupportedEncodingException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
URL=URL.replace(" ","");
// System.out.println("url="+url);
String xml= parser.getXmlFromUrl(URL);
Document doc=parser.getDomElement(xml);
NodeList n1 = doc.getElementsByTagName("item");
body = new String[n1.getLength()];
heading = new String[n1.getLength()];
for(int i = 0 ; i < n1.getLength(); i++)
{
// HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) n1.item(i);
body[i]=parser.getValue(e, "body");
heading[i]=parser.getValue(e, "headline");
// map.put("Body", parser.getValue(e,"body"));
// menuItems.add(map);
}
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return body.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return body[position];
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
// System.out.println("body="+body[position]);
if (convertView == null)
{
//this should only ever run if you do not get a view back
LayoutInflater inflater = (LayoutInflater) contxt
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.newsdescriptionrow, null);
}
TextView next =(TextView)convertView.findViewById(R.id.nextnews);
// final Gallery gal=(Gallery)convertView.findViewById(R.id.GalleryNewsDesc);
next.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
System.out.println("Inside next");
int count = Integer.parseInt((String)context.getInstance().getAppVariable("count"));
count++;
context.getInstance().setAppVariable("count", Integer.toString(count));
}
});
TextView textViewhead = (TextView) convertView
.findViewById(R.id.name_DescHeading);
textViewhead.setText(heading[position]);
TextView textView = (TextView) convertView
.findViewById(R.id.name_Desclabel);
textView.setText(body[position]);
return convertView;
}
}