我很新Android Data Binding.我正在学习本教程:数据绑定库.我正在尝试使用接收多个参数的适配器.这是我的代码:
XML
<ImageView
android:layout_width="@dimen/place_holder_size"
android:layout_height="@dimen/place_holder_size"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
app:url="@{image.imageUrl}"
app:size="@{@dimen/place_holder_size}"
/>
Run Code Online (Sandbox Code Playgroud)
绑定适配器类
public class ViewBindingAdapters extends BaseObservable {
@BindingAdapter({"bind:url", "bind:size"})
public static void loadImage(ImageView imageView, String url, int size) {
if (!Strings.isNullOrEmpty(url)) {
Picasso.with(imageView.getContext()).load(url).resize(size, size).centerCrop().into(imageView);
}
}
....
}
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
java.lang.RuntimeException:发现数据绑定错误.****/数据绑定错误****消息:在android.widget.ImageView上找不到参数类型为java.lang.String的属性'app:url'的setter.file:... li_image_item.xml loc:30:27 - 30:40****\data binding error****
有谁知道为什么?
提前致谢!
我正在尝试用一个简单的测试示例Android Data Binding.我只想在我的片段中显示"test"已EditText命名的文本"title",但此文本未显示.这是我的代码:
TestVM.java
public class TestVM extends BaseObservable {
public TestVM() {}
@Bindable
public String getText() {
return "test";
}
}
Run Code Online (Sandbox Code Playgroud)
fr_login.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="test"
type="de.theappguys.templateandroid.viewmodel.TestVM"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp"
android:text="@{test.text}"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="@android:color/black"
/>
</RelativeLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
FrLogin.java
@EFragment
public class FrLogin extends Fragment {
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
FrLoginBinding binding = DataBindingUtil.inflate(inflater, R.layout.fr_login, …Run Code Online (Sandbox Code Playgroud) 我想展示我的桌面应用程序的发布版本.我正在尝试使用此代码:
_appVersion.Content = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Run Code Online (Sandbox Code Playgroud)
问题是我没有得到我在项目属性中的发布版本.下面是它的截图:
但我得到了3.0.0.12546.有人知道问题在哪里吗?
在某些View在我的应用我显示Fragment一些Omages的RecyclerView。当Image被点击时,一个新的细节Fragment被示出(带有输入和返回过渡)。问题是当Button从 details 按下Back 时View,共享元素View有时会消失,有时不会。
这就是我所说的新细节Fragment:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
dialog.setSharedElementEnterTransition(new DetailsTransition());
dialog.setEnterTransition(new Slide());
setExitTransition(new Fade());
dialog.setSharedElementReturnTransition(new DetailsTransition());
}
dialog.setTargetFragment(this, DETAIL_FRAGMENT);
getActivity().getSupportFragmentManager()
.beginTransaction()
.addSharedElement(view, transitionmage)
.replace(R.id.container, dialog, DetailFragment.TAG)
.addToBackStack(DetailFragment.TAG)
.commit();
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这些解决方案但没有成功:
android fragment android-transitions shared-element-transition
我正在尝试运行在 MinGW32 中运行的 shell 脚本。然后我收到以下错误:
引起的:
java.io.IOException: Cannot run program "./myJooqGeneratorDB.sh", (in directory "C:\Users\admin\desktop\workspace\myProject") CreateProcess error = 193, %1 is not a valid win32 application.
我的build.gradle:
task createDb(type:Exec) {
workingDir("${project.projectDir}");
commandLine './jooq/myJooqGeneratorDb.sh'
}
Run Code Online (Sandbox Code Playgroud)
我的myJooqGeneratorDb.sh:
#!/bin/bash
rm build/project.db
mkdir build
sqlite3 build/project.db < res/raw/project_create.sql
Run Code Online (Sandbox Code Playgroud)
有人知道我的代码有什么问题吗?提前致谢!
我有一个Android应用程序,其数据库版本为1.
我在一个表中添加了一个数据列,并且可以迁移到新版本中.
我遇到的问题是如何为此进行单元测试.我需要检查旧数据是否正确插入新结构中,并以正确的方式添加和填充新列.
我最好怎么做?提前致谢.
我正在尝试使用Microsoft 翻译器 API翻译一些文本。我正在使用Retrofit 2. 这是代码:
public RestClient() {
final OkHttpClient httpClient = new OkHttpClient.Builder()
.addNetworkInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
final Request originalRequest = chain.request();
Request newRequest;
newRequest = originalRequest.newBuilder()
.header("Content-Type", "application/json")
.header("Ocp-Apim-Subscription-Key", "KEY")
.header("X-ClientTraceId", java.util.UUID.randomUUID().toString())
.build();
return chain.proceed(newRequest);
}
})
.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build();
// Build the retrofit config from our http client
final Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.cognitive.microsofttranslator.com/")
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
// Build api instance from retrofit config
api …Run Code Online (Sandbox Code Playgroud) 我正在使用FCM展位平台发送项目通知,iOS并且Android. 以下是payloads我要发送的:
{ \n "to":"user_key",\n "priority":"high",\n "content_available":true,\n "mutable_content":true,\n "data":{\n "body":"test"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n阅读文档后,发送和通过Firebase时的行为是:notificationdata payloadFCM
iOS系统
\n\nnotification如果->body未定义,您将看不到横幅。安卓
\n\ndata payload,则在 时才会收到数据background。notification_payload,system tray就会处理。事情是:
\n\n因为Android我想避免notification_payload在应用程序处于后台时通过传递来接收数据(这样 onMessageReceived() 将被调用)。但是,我不会\xc2\xb4tnotifications收到iOS.
感谢帮助/建议。
\nandroid push-notification ios firebase firebase-cloud-messaging
我正在做一个WPF,并有一个comboBox,其中包含计算机上可用端口的列表.我想改变这些物品的颜色.
我的comboBox是这些:
<ComboBox HorizontalAlignment="Left" Margin="445,0,0,0" VerticalAlignment="Top" Width="120" Loaded="ComboBoxLoaded" SelectionChanged="ComboBoxSelectionChanged" Grid.Column="1" Background="#849096" Foreground="White"/>
Run Code Online (Sandbox Code Playgroud)
这些是加载它的方法:
private void ComboBoxLoaded(object sender, RoutedEventArgs e)
{
string [] portsList = PrintPorts();
// get the ComboBox reference
var comboBox = sender as ComboBox;
// assign the ItemsSource to the List
comboBox.ItemsSource = portsList;
// make the first item selected
comboBox.SelectedIndex = 0;
}
Run Code Online (Sandbox Code Playgroud)
我尝试了很多东西,但没有任何作用.有人知道怎么做吗?谢谢!!
我正在尝试构建一个项目,但是当我尝试从命令行构建它时出现以下错误:
error: Could not find the AndroidManifest.xml file, going up from path [C:\Users\User\Documents\work
space\app\app\app\build\generated\source\apt\debug] found using dummy file []
(max atempts: file:///C:/Users/User/Documents/workspace/app/app/app/build/generated/source/apt/debug/dummy1449680140847.java)
Run Code Online (Sandbox Code Playgroud)
我的manifest.xml位于项目结构中的主要对象之下。这是我的gradle文件:
import com.android.builder.core.DefaultManifestParser
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.ponideapps.recetapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// This is important, it …Run Code Online (Sandbox Code Playgroud) 我想从图库中选择一张图片,然后保存路径。我使用此路径在RecyclerView. 我Picasso用来下载图像ImageView. 我遇到的问题如下:
当我选择图像正确显示在 RecyclerView,但如果我离开屏幕并返回,我会收到此错误:
01-19 15:05:18.984 542-840/? W/ActivityManager:权限拒绝:从...打开提供程序 com.android.providers.media.MediaDocumentsProvider 需要 android.permission.MANAGE_DOCUMENTS 或 android.permission.MANAGE_DOCUMENTS
并且图像不再显示。这是我的代码:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
AlertDialog.Builder builder = new AlertDialog.Builder(getMainActivity());
builder.setTitle("Choose Image Source");
builder.setItems(new CharSequence[] {"Gallery"},
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
Intent intent;
// GET IMAGE FROM THE GALLERY
intent = new Intent(Intent.ACTION_GET_CONTENT, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); // Show local files only …Run Code Online (Sandbox Code Playgroud) 我试图做一个简单的三元运算符,但我有一个错误,我看不到.这是我的代码:
public void setVisibility(boolean isVisible) {
View adView = ((Activity) context).findViewById(R.id.adView);
isVisible? adView.setVisibility(View.VISIBLE) : adView.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)
我得到错误:不是声明.有人知道我的错误在哪里吗?