我有一个ScrollView内部,EditText它被设置为垂直滚动.但它不会滚动.相反,整个布局滚动,每当我尝试滚动EditText.以下是代码 -
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="39dp"
android:text="Title"
android:textColor="#3bb9ff"
android:textSize="15sp" />
<EditText
android:id="@+id/Text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Title"
android:singleLine="true" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Content"
android:layout_marginTop="50dp"
android:textColor="#3bb9ff"
android:textSize="15sp"
/>
<EditText
android:id="@+id/newTodoText"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:minLines="2"
android:maxLines="7"
android:hint="Write something"
android:scrollbars = "vertical" >
</EditText>
<Button
android:id="@+id/Add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Add" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
ID为"newTodoText"的EditText在这里有问题.
android android-layout android-edittext android-scrollview android-view
我在我的应用程序中使用AppIntro库.
它有3张幻灯片.我想在显示第三张幻灯片时询问用户.为实现这一点,我正在使用afollestad的材料对话框.
AppIntro活动中的代码如下所示:
@Override
public void onNextPressed() {
if(this.pager.getCurrentItem() == 2) {
MaterialDialog dialog = new MaterialDialog.Builder(getApplicationContext())
.title("QR Code scannen")
.content("Möchtest du den QR Code scannen oder selbst eingeben?")
.positiveText("eingeben")
.negativeText("scannen")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(getApplicationContext(), RegistrationActivity.class);
startActivity(intent);
}
})
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// TODO
}
})
.show();
}
}
Run Code Online (Sandbox Code Playgroud)
运行应用程序当我滑动到第三张幻灯片时,我遇到以下问题:
com.afollestad.materialdialogs.MaterialDialog$DialogException:
Bad …Run Code Online (Sandbox Code Playgroud) 我正在使用EventBus创建一个Android应用程序,用于将异步广播发布到其他类,但我在执行期间遇到了错误.
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.google.android.gms.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class MainActivity extends AppCompatActivity {
//Globals
public String uname = null;
public double lat = 0;
public double lng = 0;
//Get GUI handles
public Button sendButton; //
public EditText username;
public Button MapButton; //
public EditText LatBox;
public EditText LngBox;
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//register EventBus
EventBus.getDefault().register(this); …Run Code Online (Sandbox Code Playgroud) 我正在使用Retrofit和OkHttp库.所以Authenticator如果获得401响应,我有哪个authanticate用户.
我build.gradle是这样的:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
Run Code Online (Sandbox Code Playgroud)
我的习惯Authenticator在这里:
import java.io.IOException;
import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
public class CustomAuthanticator implements Authenticator {
@Override
public Request authenticate(Route route, Response response) throws IOException {
//refresh access token via refreshtoken
Retrofit client = new Retrofit.Builder()
.baseUrl(baseurl)
.addConverterFactory(GsonConverterFactory.create())
.build();
APIService service = client.create(APIService.class);
Call<RefreshTokenResult> refreshTokenResult=service.refreshUserToken("application/json", "application/json", "refresh_token",client_id,client_secret,refresh_token);
//this is syncronous retrofit request
RefreshTokenResult refreshResult= refreshTokenResult.execute().body();
//check if response equals 400 , …Run Code Online (Sandbox Code Playgroud) 我使用Retrofit 2.0与Jackson转换器与REST API通信.某些请求需要授权令牌.如果我拥有的令牌已过期,我需要用另一个请求刷新它们并重复上次因此而失败的请求.
我的问题:我每次都需要手动完成它还是有任何方法可以自动化它?
这是我现在实现它的方式:
TrackerService
public interface TrackerService {
@POST("auth/sendPassword")
Call<ResponseMessage> sendPassword(@Header("app-type") String appType,
@Body User userMobile);
@FormUrlEncoded
@POST("oauth/token")
Call<TokenResponse> oathToken(@Field("client_id") String clientId,
@Field("client_secret") String clientSecret,
@Field("grant_type") String grantType,
@Field("username") String username,
@Field("password") String password);
@FormUrlEncoded
@POST("oauth/token")
Call<TokenResponse> refreshToken(@Field("client_id") String clientId,
@Field("client_secret") String clientSecret,
@Field("grant_type") String grantType,
@Field("refresh_token") String username);
@PUT("me/profile")
Call<Profile> updateProfile(@Header("app-type") String appType,
@Header("Authorization") String token,
@Body Profile profile);
}
Run Code Online (Sandbox Code Playgroud)
ServiceGateway
public class ServiceGateway {
private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
private …Run Code Online (Sandbox Code Playgroud) 我有一个有 2 个单元格的 LazyVerticalGrid。
LazyVerticalGrid(
cells = GridCells.Fixed(2),
content = {
items(moviePagingItems.itemCount) { index ->
val movie = moviePagingItems[index] ?: return@items
MovieItem(movie, Modifier.preferredHeight(320.dp))
}
renderLoading(moviePagingItems.loadState)
}
)
Run Code Online (Sandbox Code Playgroud)
LazyGridScope我正在尝试使用s修饰符显示全角加载fillParentMaxSize。
fun LazyGridScope.renderLoading(loadState: CombinedLoadStates) {
when {
loadState.refresh is LoadState.Loading -> {
item {
LoadingColumn("Fetching movies", Modifier.fillParentMaxSize())
}
}
loadState.append is LoadState.Loading -> {
item {
LoadingRow(title = "Fetching more movies")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但由于我们有 2 个单元格,因此加载会占据屏幕的一半。像这样:
有没有办法让我的加载视图占据全宽?
嘿,我正在使用Dagger2,Retrofit而且OkHttp我正面临依赖循环问题.
提供时OkHttp:
@Provides
@ApplicationScope
OkHttpClient provideOkHttpClient(TokenAuthenticator auth,Dispatcher dispatcher){
return new OkHttpClient.Builder()
.connectTimeout(Constants.CONNECT_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(Constants.READ_TIMEOUT,TimeUnit.SECONDS)
.writeTimeout(Constants.WRITE_TIMEOUT,TimeUnit.SECONDS)
.authenticator(auth)
.dispatcher(dispatcher)
.build();
}
Run Code Online (Sandbox Code Playgroud)
提供时Retrofit:
@Provides
@ApplicationScope
Retrofit provideRetrofit(Resources resources,Gson gson, OkHttpClient okHttpClient){
return new Retrofit.Builder()
.baseUrl(resources.getString(R.string.base_api_url))
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(okHttpClient)
.build();
}
Run Code Online (Sandbox Code Playgroud)
提供时APIService:
@Provides
@ApplicationScope
APIService provideAPI(Retrofit retrofit) {
return retrofit.create(APIService.class);
}
Run Code Online (Sandbox Code Playgroud)
我的APIService界面:
public interface APIService {
@FormUrlEncoded
@POST("token")
Observable<Response<UserTokenResponse>> refreshUserToken();
--- other methods like login, register ---
}
Run Code Online (Sandbox Code Playgroud)
我的TokenAuthenticator …
Android Studio自从我升级到2.0以来,我一直在被某种调试消息发送垃圾邮件
[ 05-17 17:08:32.896 81: 81 D/ ]
Socket deconnection
[ 05-17 17:08:34.896 81: 81 D/ ]
Socket deconnection
[ 05-17 17:08:36.910 81: 81 D/ ]
Socket deconnection
[ 05-17 17:08:38.912 81: 81 D/ ]
Socket deconnection
[ 05-17 17:08:40.909 81: 81 D/ ]
Socket deconnection
[ 05-17 17:08:42.918 81: 81 D/ ]
Socket deconnection
Run Code Online (Sandbox Code Playgroud)
它继续前进和前进.每当我的应用程序开始将数据推送到服务器时,它就会变得非常开心 数据正在传播,所以我不确定是什么时候发生的.
我已将此添加到我的logcat过滤器中以尝试摆脱它但它不起作用:^(?!WifiStateMachine | ConnectivityService | ConnectivityManager | dalvikvm | IInputConnectionWrapper)
有谁知道怎么摆脱这个?这让我很难调试我的应用程序并跟踪我的日志.
感谢您的时间
编辑
感谢您的评论,指出Genymotion可以指向Android SDK并使用那adb.exe将停止这个愚蠢的垃圾邮件在genymotion主应用程序下,单击选项 - > ADB …
我使用RecyclerView带StaggeredGridLayoutManager.
我想要这个StaggeredGridLayoutManager或哪个LayoutManager占据空区域,如果有的话.例如,如果我设置spanCount = 3,它必须占用所有屏幕宽度,即使我有2个项目或1个项目.在StaggeredGridLayoutManager我可以完全跨越单行:setFullSpan(true);但不能跨越2个项目只有一行.
我的代码RecyclerView:
StaggeredGridLayoutManager sglm= new StaggeredGridLayoutManager(spanCount,StaggeredGridLayoutManager.VERTICAL);
sglm.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
Run Code Online (Sandbox Code Playgroud)
我尝试过AsymmetricGridView和 twoway-view,但总有一个空白区域
我收集了Facebook App的一些截图:
这里是Google Keep App,因为你可以看到每行的行高是固定的,但项目的宽度是灵活的,我从未见过Google Keep的任何空白区域:
当我使用它时,总会有一个空白区域,因为你可以看到图像的黑色部分是空的.我想RecyclerView通过扩展我的行来占据该区域,就像在Google Keep应用中一样:
我访问了这个页面:android-how-to-create-a-facebook-like-images-gallery-grid但它没有帮助我.
这是我访问过的另一个页面:grid-of-images-like-facebook-for-android
是否有人使用RecyclerView或View类似的?有人可以建议我任何方式或任何想法或指导我到我必须开始的地方?
我正在尝试RecyclerView从Realm数据库填充中删除一个项目,我收到以下错误:
java.lang.IllegalStateException: Illegal State:
Object is no longer valid to operate on. Was it deleted by another thread?
Run Code Online (Sandbox Code Playgroud)
假设 我猜我正在尝试访问它已被删除,但我不明白在哪里.
上下文: 我正在显示城市列表,并且long在项目上单击会显示一个要求确认删除的对话框.
该项目在数据库中被删除,因为当我重新启动应用程序时,它已不存在了.
领域到ArrayList
public static ArrayList<City> getStoredCities(){
RealmQuery<City> query = getRealmInstance().where(City.class);
final RealmResults<City>results =
realm.where(City.class)
.findAllSorted("timestamp", Sort.DESCENDING);
results.size();
ArrayList<City> cityArrayList = new ArrayList<>();
for(int i = 0; i< results.size(); i++){
cityArrayList.add(results.get(i));
}
return cityArrayList;
}
Run Code Online (Sandbox Code Playgroud)
对话框代码
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
RealmHelper.removeCity(cityArrayList.get(position));
cityArrayList.remove(position);
mRecyclerView.removeViewAt(position);
mCityListAdapter.notifyItemRemoved(position);
mCityListAdapter.notifyItemRangeChanged(position, cityArrayList.size());
mCityListAdapter.notifyDataSetChanged(); …Run Code Online (Sandbox Code Playgroud)