我有一个应用程序,我想在其中实现一个双抽屉 - 一个来自左边,一个来自右边.左抽屉用于app导航,右抽屉用于结果过滤.
所以,布局是这样的:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_grey"
android:orientation="vertical">
<GridView
android:id="@+id/gridview"
style="@style/GridViewStyle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:horizontalSpacing="7dp"
android:stretchMode="columnWidth"
android:verticalSpacing="7dp" />
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
<ListView
android:id="@+id/right_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
你可以在这里清楚地看到"left_drawer"和"right_drawer",以及它们各自的重力 - "开始"和"结束"这实际上是有效的!你可以将它们全部拉出来.
问题是,当我实现DrawerToggle时 - 它只打开左抽屉,而不是关闭右抽屉,所以如果打开右抽屉我按下DrawerToggle按钮 - 左抽屉也打开,并重叠右抽屉.
我想要获得以下几种解决方案:
我还没有想到如何做到这一点,因为DrawerToggle接受DrawerLayout本身作为参数,而不是单个抽屉......
我正在使用支持库.
有人有主意吗?先感谢您.
我试图在颤动中使用带有 Dio 的拦截器,我必须处理令牌过期。以下是我的代码
Future<Dio> getApiClient() async {
token = await storage.read(key: USER_TOKEN);
_dio.interceptors.clear();
_dio.interceptors
.add(InterceptorsWrapper(onRequest: (RequestOptions options) {
// Do something before request is sent
options.headers["Authorization"] = "Bearer " + token;
return options;
},onResponse:(Response response) {
// Do something with response data
return response; // continue
}, onError: (DioError error) async {
// Do something with response error
if (error.response?.statusCode == 403) {
// update token and repeat
// Lock to block the incoming request until the token updated
_dio.interceptors.requestLock.lock(); …
Run Code Online (Sandbox Code Playgroud) 我正在android studio中使用actionbar sherlock构建一个演示应用程序,我遇到了问题,在以下链接中提到: - 以前的问题
现在按照上面链接上发布的回复后我做了一些更改,现在我正面对这个
Gradle: Execution failed for task ':SherlockTest:processDebugManifest'.
> Manifest merging failed. See console for more info.
Run Code Online (Sandbox Code Playgroud)
我的应用程序清单文件是: -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sherlocktest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.sherlocktest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
和actionbar sherlock清单文件是: -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="440"
android:versionName="4.4.0"
package="com.actionbarsherlock">
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16"/>
<application/>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚这里有什么问题,请帮忙
android android-manifest actionbarsherlock android-studio build.gradle
我正在使用android studio进行应用程序开发,我正在使用它的第一个版本,每当补丁可用时我会不断更新它.最近我将我的android工作室更新到最新版本,即0.2.9现在我面临问题而创建新项目.
每次我得到这个异常消息框
The following dependencies were not resolvable. See your build.gradle file for details.
- com.android.support:appcompat-v7:18.0.0
Run Code Online (Sandbox Code Playgroud)
我对于出了什么问题一无所知!!
ps:以前的项目工作正常
寻求建议:)
我正在使用AsyncHttpClient
链接进行http调用,但现在我们的服务器已迁移到HTTPS,我得到了异常javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
.有没有人尝试使用此库进行https调用?
AsyncHttpClient的初始化: -
AsyncHttpClient client = new AsyncHttpClient();
PersistentCookieStore myCookieStore = new PersistentCookieStore(
getActivity());
// List<Cookie> cookies = myCookieStore.getCookies();
myCookieStore.clear();
// cookies = myCookieStore.getCookies();
client.setCookieStore(myCookieStore);
client.get(loginUrl, new JsonHttpResponseHandler() {
@Override
public void onStart() {
super.onStart();
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onFinish() {
super.onFinish();
progressBar.setVisibility(View.GONE);
}
@Override
public void onSuccess(int statusCode, JSONObject userInfo) {
super.onSuccess(statusCode, userInfo);
String errorMsg = null;
try {
errorMsg = userInfo.getString("error");
} catch (JSONException e) {
e.printStackTrace();
}
if …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 SliverApp Bar 在我的应用程序中实现折叠工具栏,但问题是当 SliverAppBar 折叠时,SliverAppBar 与我的内容重叠,我附上 gif 以供更多理解,
绿色背景中的内容位于工具栏下方,我想避免这种情况,任何线索都会受到赞赏。
@override
Widget build(BuildContext context) {
// TODO: implement buildr
var _tabs = {"1", "2", "3"};
return Scaffold(
backgroundColor: Colors.white,
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
child: SliverAppBar(
expandedHeight: 250.0,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
background: Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
image: DecorationImage(
fit: BoxFit.fill,
image: CachedNetworkImageProvider(
newsPost.photos[0].url),
),
),
)),
forceElevated: innerBoxIsScrolled,
))
];
},
body: SafeArea(
top: false,
bottom: …
Run Code Online (Sandbox Code Playgroud) 我正在使用ActionBar Sherlock和Android Studio开发一个演示应用程序.Android Studio版本为0.2.2,gradle版本为1.6,插件版本为0.5.1,我遵循以下教程: -
www.grokkingandroid.com
showlabor.blogspot.ca
我收到以下错误: -
Gradle: Execution failed for task ':libraries:ActionBarSherlock:actionbarsherlock:compileReleaseAidl'.tried to access class com.android.build.gradle.internal.tasks.DependencyBasedCompileTask$DepFileProcessor from class com.android.build.gradle.internal.tasks.DependencyBasedCompileTask
Run Code Online (Sandbox Code Playgroud)
actionbarsherlock build.gradle文件是这样的: -
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs …
Run Code Online (Sandbox Code Playgroud) android gradle actionbarsherlock android-studio build.gradle
有没有人知道为什么android:nextFocusDown attibute在我们设置onClick时停止工作?
在下面的示例中,我们定义了一些具有此属性的EditText:
<TableRow
android:weightSum="1"
android:gravity="center">
<EditText
android:id="@+id/txtChave1"
android:maxLength="4"
android:gravity="center"
android:textSize="16dp"
android:layout_height="wrap_content"
android:layout_weight=".23"
android:layout_width="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:singleLine="true"
android:selectAllOnFocus="true"
android:inputType="textCapCharacters"
android:nextFocusDown="@+id/txtChave2"></EditText>
<EditText
android:id="@+id/txtChave2"
android:maxLength="4"
android:gravity="center"
android:textSize="16dp"
android:layout_height="wrap_content"
android:layout_weight=".23"
android:layout_width="0dp"
android:layout_marginRight="5dp"
android:singleLine="true"
android:selectAllOnFocus="true"
android:inputType="textCapCharacters"
android:nextFocusDown="@+id/txtChave3"></EditText>
<EditText
android:id="@+id/txtChave3"
android:maxLength="4"
android:gravity="center"
android:textSize="16dp"
android:layout_height="wrap_content"
android:layout_weight=".23"
android:layout_width="0dp"
android:layout_marginRight="5dp"
android:singleLine="true"
android:selectAllOnFocus="true"
android:inputType="textCapCharacters"
android:nextFocusDown="@+id/txtChave4"></EditText>
<EditText
android:id="@+id/txtChave4"
android:maxLength="4"
android:gravity="center"
android:textSize="16dp"
android:layout_height="wrap_content"
android:layout_weight=".23"
android:layout_width="0dp"
android:layout_marginRight="5dp"
android:singleLine="true"
android:selectAllOnFocus="true"
android:inputType="textCapCharacters"></EditText>
</TableRow>
Run Code Online (Sandbox Code Playgroud)
如上所述,当用户点击虚拟键盘上的"下一个按钮"时,焦点会按预期更改...但是,如果我们设置onClick属性,则android:nextFocusDown将不再起作用.
<EditText
android:id="@+id/txtChave1"
android:maxLength="4"
android:gravity="center"
android:textSize="16dp"
android:layout_height="wrap_content"
android:layout_weight=".23"
android:layout_width="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:singleLine="true"
android:selectAllOnFocus="true"
android:inputType="textCapCharacters"
android:nextFocusDown="@+id/txtChave2"
android:onClick="onClickHandler">
</EditText>
Run Code Online (Sandbox Code Playgroud)
有什么建议?
非常感谢!
我试图在我的选项卡中显示图标,我正在使用tablayout和viewpager,但是当我调用tablayout.setupWithViewPager(viewpager)时,我的图标正在消失Min sdk is 16 Target is 24 Support library 24.2.1
这就是我设置标签的方式: -
private void setUpTabs(){
tabs.setupWithViewPager(viewpager);
TabLayout.Tab discoverTab = tabs.newTab();
TabLayout.Tab placesTab = tabs.newTab();
TabLayout.Tab rewardTab = tabs.newTab();
Drawable discover = ContextCompat.getDrawable(this, R.drawable.discover);
discover.setAlpha(255);
discover.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
Drawable places = ContextCompat.getDrawable(this, R.drawable.places);
places.setAlpha(55);
places.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
Drawable rewards = ContextCompat.getDrawable(this, R.drawable.rewards);
rewards.setAlpha(55);
rewards.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
discoverTab.setIcon(discover);
placesTab.setIcon(places);
rewardTab.setIcon(rewards);
tabs.addTab(discoverTab,0);
tabs.addTab(placesTab,1);
tabs.addTab(rewardTab,2);
}
Run Code Online (Sandbox Code Playgroud)
ViewPager: -
private void setUpViewPager(){
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(DiscoverFragment.getFragment(null),"Discover");
adapter.addFrag(PlacesFragment.getFragment(null),"Places");
adapter.addFrag(RewardsFragment.getFragment(null),"Rewards");
viewpager.setAdapter(adapter);
}
Run Code Online (Sandbox Code Playgroud)
ViewPagerAdapter: -
public class ViewPagerAdapter extends …
Run Code Online (Sandbox Code Playgroud) android android-layout android-viewpager material-design android-tablayout
android ×7
build.gradle ×2
dart ×2
flutter ×2
drawerlayout ×1
gradle ×1
http ×1
https ×1
networking ×1