我使用了这个库:https ://github.com/johannilsson/android-pulltorefresh
效果很好,但在 ListView 中很简单(简单就是我在单元格 android 模式中所说的)。
我将 Adpter 放入我的自定义 ListView 到带有图像、标题和描述的单元格中。
我的课上有适配器:
public class extends Main_podcast ListActivity implements {OnItemClickListener
private Bitmap pathImgSmal;
/ ** Called When the activity is first created. * /
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
Mybundle bundle = new Bundle ();
mybundle.putString ("podcastnumber", "0");
/ / Check for connection and starts downloading the XML
Connected conected Boolean = (this);
if (conected == true) {
DoInBackground new (). execute ();
Else {}
new AlertDialog.Builder (Main_podcast.this)
. SetTitle ("Alert!")
. SetMessage ("Unable to connect to the Internet," +
"Check your network or try again later.")
. SetNeutralButton ("OK"
new DialogInterface.OnClickListener () {
public void onClick (DialogInterface dialog,
int which) {}
}). Show ();
}
}
/ / Method calls the XML Parser
public void do_update ()
{
PodcastParser.parse ();
}
/ / Method that populates the list view with XML parameters
public void populate_listview ()
{
List <Itens> podcastList <Itens> = new ArrayList ();
for (int i = 0; i <arraysPodcast.PodcastTitle.length; i + +) {
end item Items = new Items ();
item.setTitle (arraysPodcast.PodcastTitle [i]);
item.setData (arraysPodcast.PodcastData [i]);
item.setImage (arraysPodcast.ArrayIMGPodcast [i]);
podcastList.add (item);
}
setListAdapter (new PodcastAdapter (this, podcastList));
ListView shot getListView = ();
shot.setOnItemClickListener ((OnItemClickListener) this);
}
public void onItemClick (AdapterView <?> arg0, View v, int position, long id) {
/ / Start the Activity podcast regarding your number from the list
Myintent intent = new Intent ("com.example.player.PODCAST");
Mybundle bundle = new Bundle ();
mybundle.putInt ("podcastnumber" position);
myintent.putExtras (mybundle);
startActivity (myintent);
}
private class extends DoInBackground AsyncTask <Void, Void, Void>
implements DialogInterface.OnCancelListener
{
ProgressDialog private dialog;
protected void OnPreExecute ()
{
dialog = ProgressDialog.show (Main_podcast.this, "", "Loading Podcasts ...", true);
}
protected void doInBackground (Void. unused ..)
{
do_update ();
return null;
}
OnPostExecute protected void (Void unused)
{
dialog.dismiss ();
populate_listview ();
}
public void onCancel (DialogInterface dialog)
{
cancel (true);
dialog.dismiss ();
}
}
public static boolean Connected (Context context) {
try {
= ConnectivityManager cm (ConnectivityManager)
context.getSystemService (Context.CONNECTIVITY_SERVICE);
LogSync String = null;
LogToUserTitle String = null;
if (cm.getNetworkInfo (ConnectivityManager.TYPE_MOBILE). isConnected ()) {
LogSync + = "\ nConectado 3G Internet";
LogToUserTitle + = "Connected to 3G Internet";
return true;
} Else if (cm.getNetworkInfo (ConnectivityManager.TYPE_WIFI). IsConnected ()) {
LogSync + = "\ nConectado WIFI Internet";
LogToUserTitle + = "Connected to Wireless Internet";
return true;
Else {}
LogSync + = "\ nYou have internet connection";
LogToUserTitle + = "Do not have an internet connection";
return false;
}
} Catch (Exception e) {
return false;
}
}
} / / Class
问题是,如何使用自定义单元库 johannilsson 实现我的类?
欢迎任何帮助!