- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用了这个库:https://github.com/johannilsson/android-pulltorefresh
效果很好,但在 ListView 中很简单(简单就是我在 cell android 模式中所说的)。
我在我的自定义 ListView 中使用了一个 Adpter 到带有图像、标题和描述的单元格。
我的类与适配器:
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 实现我的类?
欢迎任何帮助!
最佳答案
决定如下:
public class PullToRefreshActivity extends ListActivity implements OnItemClickListener {
private LinkedList<String> mListItems;
private List<Itens> podcastList;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pull_to_refresh);
// Set a listener to be invoked when the list should be refreshed.
// ======================================================
Bundle mybundle = new Bundle();
mybundle.putString("podcastnumber", "0");
//verifica se há conexao e inicia download do XML
Boolean conected = Conectado(this);
if(conected == true){
new DoInBackground().execute();
}else{
new AlertDialog.Builder(PullToRefreshActivity.this)
.setTitle("Alerta!")
.setMessage("Não foi possível estabelecer uma conexão com a Internet," +
"verifique sua rede ou tente novamente mais tarde.")
.setNeutralButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {}
}).show();
}
// ======================================================
((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Do work to refresh the list here.
new DoInBackground().execute();
}
});
}
// ==================================================================
public void do_update()
{
PodcastParser.parse();
}
//metodo que preenche a list view com parametros do XML
public void populate_listview()
{
podcastList = new ArrayList<Itens>();
for (int i = 0; i < arraysPodcast.PodcastTitle.length; i++) {
final Itens item = new Itens();
item.setTitle(arraysPodcast.PodcastTitle[i]);
item.setData(arraysPodcast.PodcastData[i]);
item.setImage(arraysPodcast.ArrayIMGPodcast[i]);
podcastList.add(item);
}
setListAdapter(new PodcastAdapter(this, podcastList));
((PullToRefreshListView) getListView()).setOnItemClickListener((OnItemClickListener) this);
}
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
//Inicia Activity da podcast referente a seu numero da lista
Intent myintent = new Intent("com.example.player.PODCAST");
Bundle mybundle = new Bundle();
mybundle.putInt("podcastnumber", (position-1));
Log.e("posicao na lista",""+position);
myintent.putExtras(mybundle);
startActivity(myintent);
}
private class DoInBackground extends AsyncTask<Void, Void, Void>
implements DialogInterface.OnCancelListener
{
private ProgressDialog dialog;
protected void onPreExecute()
{
dialog = ProgressDialog.show(PullToRefreshActivity.this, "", "Carregando Podcasts...", true);
}
protected Void doInBackground(Void... unused)
{
PodcastAdapter.topBar=true;
do_update();
return null;
}
protected void onPostExecute(Void unused)
{
((PullToRefreshListView) getListView()).onRefreshComplete();
dialog.dismiss();
populate_listview();
}
public void onCancel(DialogInterface dialog)
{
cancel(true);
dialog.dismiss();
}
}
public static boolean Conectado(Context context) {
try {
ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
String LogSync = null;
String LogToUserTitle = null;
if (cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected()) {
LogSync += "\nConectado a Internet 3G ";
LogToUserTitle += "Conectado a Internet 3G ";
return true;
} else if(cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()){
LogSync += "\nConectado a Internet WIFI ";
LogToUserTitle += "Conectado a Internet WIFI ";
return true;
} else {
LogSync += "\nNão possui conexão com a internet ";
LogToUserTitle += "Não possui conexão com a internet ";
return false;
}
} catch (Exception e) {
return false;
}
}
}
关于java - PullToRefresh 与自定义单元格 listView Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10874946/
我正在尝试使用 https://github.com/chrisbanes/Android-PullToRefresh/ .我跟着这个例子,但得到了错误java.lang.NoSuchFieldErr
我有一个带有原型(prototype)单元格的表格 View 。 我的 viewDidLoad 方法中有以下代码, _refreshControl = [[UIRefreshControl alloc
有没有办法检测何时在 Parse - PFQueryTableViewController 上调用 pullToRefresh ? 我在 Objective-C 上找到了一些,但在 swift 上没有
我正在开发一个应用程序,您可以在其中查看公交车站时间表。并且用户可以使用 ActionBar PullToRefresh (Library) 进行刷新。我的应用还在 KitKat 上启用了半透明状态栏
昨天,我使用了来自的组件调用 PullToRefreshList https://github.com/johannilsson/android-pulltorefresh并将其安装到我的项目中。 它
我正在使用 PullToRefresh 库: https://github.com/johannilsson/android-pulltorefresh/ 我遇到的问题是列表很短并且没有使用全屏: “
ScreenShot 我在应用程序中集成了 PullToRefresh。但是当我使用 PullToRefreshListView 拉起刷新时,它以变形的方式移动。 ProgressBar 直接移动到
目前我正在使用 Styles.xml 结合 java 代码来定义 PullToRefresh 定制。我只想通过 java 代码进行所有自定义,而不是在 XML 中定义它们。我能否以编程方式实现所有定制
我们刚刚开始使用 Sencha Touch 2,需要集成 https://github.com/j-mcnally/Sencha2-PullToRefresh 我刚刚开始使用 Sencha,无法在文档
我正在尝试将 ActionBar-PushToRefresh 添加到我的项目中。我按照 Chris Banes Github 的说明进行操作:Github ActionBar-PullToRefres
我正在尝试实现 chrisbanes's Android-PullToRefresh在我的应用程序中。但到目前为止,我得到的只是一个空洞的观点。如果我将 ListView 更改为 Android 小部
我有chrisbanes PullToRefresh lib在我的项目中工作。现在我需要拦截滚动事件来添加一些逻辑,似乎库准备设置onScrollListener,我尝试添加一个 myList.set
我在执行 Johan Nilsson 在 https://github.com/johannilsson/android-pulltorefresh 找到的 android-pulltorefresh
我正在使用 chrisbanes's Android-PullToRefresh在我的应用程序中。 我需要在第一次启动 fragment 时禁用 pulltorefresh 功能 - 当列表为空并且项
有没有人实践过使用 Pull to refresh list with Pinned section header?我用 Android-PullToRefresh lib 与我的列表,我想添加在列表
我用过Chris Banes implementation of pull to refresh list view 对于我的应用程序。问题是,如果我将 ListView 的可见性设置为消失或不可见,
我正在使用这个 PullToRefresh 插件: https://github.com/BoxFactura/pulltorefresh.js#api 它运行良好,但我的页面上有一个带有 div 内
谁能帮我在 build.gradle Android Studio 中添加这个库。 https://github.com/chrisbanes/Android-PullToRefresh 我知道它已被
我试图从 Material 库中实现 PullToRefresh 组件,但即使一对一复制 Google 自己的代码,滑动也不会触发任何内容。 https://developer.android.com
我正在使用 Chris Banes ActionBar-PullToRefresh在我的 ListFragment 上。 除了 ListView 为空时,一切正常。当 ListView 为空(并且空文
我是一名优秀的程序员,十分优秀!