所以,我有ScrollView一个孩子 - 一个LinearLayout有两个孩子:a TextView和a ViewPager.ViewPager包含许多元素的布局,这就是为什么我需要垂直滚动的能力.只有页面ViewPager可以水平滚动(即:我只想在其中水平滑动ViewPager).那一个TextView不能水平滚动,但应该与我一起滚动ViewPager.
简单?没有.
我在StackOverflow中看到了非常类似的问题(这里,这里,这里和这里).所有建议的解决方案都不适合我:(
我看到的是这个 < - 我的甜蜜UI :),但我无法垂直滚动:(
在ViewPager中嵌入ScrollViews不是一个选项 - UI的设计禁止这样做.
也许这是我用编程方式填充视图寻呼机中的每个页面的东西?嗯...
任何建议,将不胜感激.
我的代码:
activity_main.xml中:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/linearLayoutGeneral"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tvText"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:text="Test text" />
<android.support.v4.view.ViewPager
android:id="@+android:id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
ViewPager中的每个页面都有这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) android android-fragments android-scrollview android-viewpager
我正在编写一个连接到servlet的程序,感谢a HttpURLConnection但是我在查看url时卡住了
public void connect (String method) throws Exception {
server = (HttpURLConnection) url.openConnection ();
server.setDoInput (true);
server.setDoOutput (true);
server.setUseCaches (false);
server.setRequestMethod (method);
server.setRequestProperty ("Content-Type", "application / xml");
server.connect ();
/*if (server.getResponseCode () == 200)
{
System.out.println ("Connection OK at the url:" + url);
System.out.println ("------------------------------------------- ------- ");
}
else
System.out.println ("Connection failed");
}*/
Run Code Online (Sandbox Code Playgroud)
我收到了错误:
java.net.ProtocolException:读取输入后无法写入输出.
如果我用注释中的代码检查网址,但不幸的是它完美地工作,我需要检查网址,所以我认为问题来自getResponseCode方法,但我不知道如何解决它
非常感谢你
最近的android库就在几天前发布了,但是我希望它SnackBar出现在屏幕的顶部,最好是在RelativeLayout中,因为它是父视图.
怎样才能改变SnackBar这我相信是的初始对准layout_alignParentBottom来layout_alignParentTop?
android material-design snackbar android-design-library android-snackbar
我正在使用新的firebase sdk for android并使用真正的数据库功能.当我使用getValue(simple.class)一切都很好.但是当我想解析一个子类的类时,母类的所有属性都是null,并且我有这种类型的错误:
在类uk.edume.edumeapp.TestChild上找不到名称的setter/field
public class TestChild extends TestMother {
private String childAttribute;
public String getChildAttribute() {
return childAttribute;
}
}
public class TestMother {
protected String motherAttribute;
protected String getMotherAttribute() {
return motherAttribute;
}
}
Run Code Online (Sandbox Code Playgroud)
这个功能
snapshot.getValue(TestChild.class);
Run Code Online (Sandbox Code Playgroud)
motherAttribute属性是null,我得到
在类uk.edume.edumeapp.TestChild上找不到关于motherAttribute的setter/field
我解析的Json是:
{
"childAttribute" : "attribute in child class",
"motherAttribute" : "attribute in mother class"
}
Run Code Online (Sandbox Code Playgroud) java android jackson json-deserialization firebase-realtime-database
我在使用该Location.distanceTo方法计算距离时遇到问题.
private class MyLocationOverlay1 extends MyLocationOverlay {
@Override
public void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when)
super.drawMyLocation(canvas,mapView,lastFix,myLocation,when);
Location bLocation = new Location("reverseGeocoded");
bLocation.setLatitude(FindList.gpslat); // Value = 3.294391E7
bLocation.setLongitude(FindList.gpslong); // Value = -9.6564615E7
Location aLocation = new Location("reverseGeocoded");
aLocation.setLatitude(myLocation.getLatitudeE6()); // Value = 3.2946164E7
aLocation.setLongitude(myLocation.getLongitudeE6()); // Value = -9.6505141E7
aLocation.set(aLocation); // Don't think I need this
bLocation.set(bLocation); // Don't think I need this either
int distance = (int)aLocation.distanceTo(bLocation); // Value = 12637795 ???
String str = …Run Code Online (Sandbox Code Playgroud) 我创建了自定义复合视图,其中包含拍摄照片的功能.
我这样称呼它(从视图):
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
((Activity)mContext).startActivityForResult(intent, index);
Run Code Online (Sandbox Code Playgroud)
这部分很好用.我不知道怎么做是如何onActivityResult在我的自定义视图中实现的?
或者我应该在Activity中捕获这个并重新路由到我的视图中?看起来不是很好的解决方案..
我用了一个PagerAdapter.我有很多元素,所以我不会在同一时间加载所有元素.我重新加载适配器,我通过新元素更改旧元素.例如,我有4个元素,当我到达最后一个元素时,我重新加载元素,并且我调用setCurentItem(1)能够在第一个位置显示viewpager.我做了很多测试.我放:
viewPager.setCurrentItem(1,false); //But not scroll, put drastically the new page.
viewPager.setCurrentItem(1);
Run Code Online (Sandbox Code Playgroud)
我试图修改onPageScrollStateChanged(int arg0),我只有3个视图,总是在中间ubicate.
if (arg0 == ViewPager.SCROLL_STATE_DRAGGING) {
if(focusedPage==2) {
//Modify adapter
viewPager.setCurrentItem(1,false);
}else if(focusedPage==0){
//Modify adapter
viewPager.setCurrentItem(1,false);
}
Run Code Online (Sandbox Code Playgroud)
我试着修改 onPageSelected(int arg0)
focusedPage=arg0;
Run Code Online (Sandbox Code Playgroud)
使用最后一个示例,我立即滚动视图,但始终位于最后一页.有谁知道我可以滑动.
谢谢
我有一个RecyclerView包裹在一个LinearLayout,它按预期完美地工作.我可以看到RecyclerView填充的所有数据.到现在为止还挺好.
当我裹LinearLayout在ScrollView,在RecyclerView一片空白.我内心没有看到任何东西RecyclerView.为什么?如何使这项工作.
该页面是a中的一个选项卡ViewPagerIndicator,因此该选项卡中的所有内容都必须位于ScrollView.
谢谢你的帮助.
我在ToolbarLollipop项目中添加了一个.但是,我在设计风格方面遇到了麻烦Toolbar.我的标题Toolbar似乎有一个粗体字,但我希望它是斜体.知道怎么做到这一点?我试过玩弄actionbar-style,没有运气.
我已经在Toolbarwith 上设置了一个样式,app:theme="@style/toolbar"而我的@style/toolbar(父母ThemeOverlay.AppCompat.ActionBar)是我正在玩的地方没有好结果.
当我使用它GlobalLayoutListener来查看softKeyboard是否被打开时,片段在被销毁后不再是garbageCollected.
我所做的:
onDestroy()片段中的监听器null在onDestroy()onDestroy()仍在泄漏碎片.
有没有人有类似的问题,并知道它的修复?
我的onDestroy:
@Override
public void onDestroy(){
Log.d(TAG , "onDestroy");
if(Build.VERSION.SDK_INT < 16){
view.getViewTreeObserver().removeGlobalOnLayoutListener(gLayoutListener);
}else{
view.getViewTreeObserver().removeOnGlobalLayoutListener(gLayoutListener);
}
view = null;
gLayoutListener = null;
super.onDestroy();
}
Run Code Online (Sandbox Code Playgroud)