这是我使用 SwipeRefreshLayout 的 webview 应用程序代码。但是 SwipeRefresh 不起作用,请检查它。但所有其他事情都正常工作。像webview,菜单按钮。
下面是我的 activity_main.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:id="@+id/webView"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的MainActivity.java文件
public class MainActivity extends AppCompatActivity {
WebView webView;
SwipeRefreshLayout swipe;
@Override
public boolean onCreateOptionsMenu (Menu manu){
getMenuInflater().inflate(R.menu.main, manu);
return true;
}
@Override
public boolean onOptionsItemSelected (MenuItem item){
int id=item.getItemId();
if(id==R.id.id_about){
Intent intentabout=new Intent(MainActivity.this, About.class);
startActivity(intentabout);
return true;
}
if(id==R.id.id_terms){
return true;
}
if(id==R.id.id_privacy){
return true;
}
return true;
}
@Override
public …Run Code Online (Sandbox Code Playgroud)