当客户端从列表项中选择一项时,我想显示弹出窗口。现在我的代码是这样工作的,当我单击一个项目时,它将指向显示下载链接的新布局。
我想问的是,如何让我的 DownloadText 类成为弹出窗口?所以客户端可以看到链接而无需移动到其他布局?
任何人,请帮助我如何做到这一点。非常感谢您
DownloadDetail.java - 这个是用来显示列表项的
public class DownloadDetail extends ListActivity {
public Koneksi linkurl;
String SERVER_URL;
private RSSFeed myRssFeed = null;
public class MyCustomAdapter extends ArrayAdapter<RSSItem> {
public MyCustomAdapter(Context context, int textViewResourceId,
List<RSSItem> list) {
super(context, textViewResourceId, list);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
View row = convertView;
if(row==null){
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.rss_row, parent, false);
}
TextView listTitle=(TextView)row.findViewById(R.id.juduldl);
listTitle.setText(myRssFeed.getList().get(position).getTitle());
/*TextView listPubdate=(TextView)row.findViewById(R.id.status);
listPubdate.setText(myRssFeed.getList().get(position).getPubdate());*/
return row;
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rss);
Bundle bundle = this.getIntent().getExtras();
String param1 = bundle.getString("keyIdc");
String param2 = bundle.getString("keyUserId");
SERVER_URL = SERVER_URL+"?idc="+param1+"&un="+param2;
try {
linkurl = new Koneksi(this);
SERVER_URL = linkurl.getUrl();
SERVER_URL += "/mobile/DownloadDetail.php?idc="+param1+"&idu="+param2;
URL rssUrl = new URL(SERVER_URL);
SAXParserFactory mySAXParserFactory = SAXParserFactory.newInstance();
SAXParser mySAXParser = mySAXParserFactory.newSAXParser();
XMLReader myXMLReader = mySAXParser.getXMLReader();
RSSHandler myRSSHandler = new RSSHandler();
myXMLReader.setContentHandler(myRSSHandler);
InputSource myInputSource = new InputSource(rssUrl.openStream());
myXMLReader.parse(myInputSource);
myRssFeed = myRSSHandler.getFeed();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (myRssFeed!=null)
{
TextView feedTitle = (TextView)findViewById(R.id.feedtitle);
TextView feedDescribtion = (TextView)findViewById(R.id.feeddescription);
TextView feedPubdate = (TextView)findViewById(R.id.feedPubdate);
TextView feedLink = (TextView)findViewById(R.id.feedlink);
feedTitle.setText(myRssFeed.getTitle());
feedDescribtion.setText(myRssFeed.getDescription());
feedPubdate.setText(myRssFeed.getPubdate());
feedLink.setText(myRssFeed.getLink());
/*ArrayAdapter<RSSItem> adapter =
new ArrayAdapter<RSSItem>(this,
android.R.layout.simple_list_item_1,myRssFeed.getList());
setListAdapter(adapter);*/
MyCustomAdapter adapter =
new MyCustomAdapter(this, R.layout.rss_row, myRssFeed.getList());
setListAdapter(adapter);
}
}
protected void onListItemClick(ListView l, View v, int position, long id) {
Intent intent = new Intent(this,DownloadText.class);
Bundle bundle = new Bundle();
bundle.putString("keyNama", myRssFeed.getItem(position).getTitle());
bundle.putString("keyReference", myRssFeed.getItem(position).getDescription());
bundle.putString("keyIdc", myRssFeed.getItem(position).getLink());
intent.putExtras(bundle);
startActivity(intent);
}
}
DownloadText.java - 此代码用于显示链接
public class DownloadText extends Activity{
public Koneksi linkurl;
public Kondownload linkurl2;
String url;
String SERVER_URL;
String SERVER_URL2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.linkdownload);
TextView mTextLink = (TextView) findViewById(R.id.LinkDownload);
Bundle bundle = this.getIntent().getExtras();
String param1 = bundle.getString("keyIdc");
String param2 = bundle.getString("keyReference");
if(param2.endsWith(".pdf"))
{
linkurl = new Koneksi(this);
SERVER_URL = linkurl.getUrl();
SERVER_URL += "/moodledata/"+param1+"/"+param2;
mTextLink.setText(SERVER_URL);
Pattern pattern = Pattern.compile(SERVER_URL);
Linkify.addLinks(mTextLink, pattern, "");
}
else
{
linkurl2 = new Kondownload(param2);
SERVER_URL2 = linkurl2.getUrl();
mTextLink.setText(SERVER_URL2);
Pattern pattern = Pattern.compile(SERVER_URL2);
Linkify.addLinks(mTextLink, pattern, "");
}
}
}
链接下载.xml
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/AbsoluteLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
tools:ignore="Deprecated" >
<TextView
android:id="@+id/Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="6dip"
android:layout_y="9dip"
android:gravity="center"
android:text="@string/silahkan_klik_link_di_bawah_ini_untuk_mengunduh_file"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/LinkDownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="6dip"
android:layout_y="133dip"
android:text="@string/ld" >
</TextView>
</AbsoluteLayout>