我创建了一个JSON文件:
$json = array(
"Sample" =>array(
"context" => $context,
"date" => $date
)
);
$url= "sample.json";
$myfile = fopen($url, "w") or die("Unable to open file!");
fwrite($myfile, json_encode($json));
fclose($myfile);
Run Code Online (Sandbox Code Playgroud)
我需要将其保存为UTF-8,我不能JSON_UNESCAPED_UNICODE在PHP 5.3中使用.那我现在该怎么办?
我想通过square picasso创建web应用程序,但如果图像url包含波斯字符(ا,ب,ج,ی,...)Picasso不加载图像.
这个网址不起作用:
Picasso.with(mContext).load("http://www.shutterstock.ir/thumbs/10006/74601661-????-???-???-?????-?????-??-??-??-?????-?-?????-????.jpg")
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.face_top_image).noFade().resize(100, 100)
.into(imageView);
Run Code Online (Sandbox Code Playgroud)
这个网址工作
Picasso.with(mContext).load("http://www.shutterstock.ir/thumbs/10006/74601661-%DA%AF%D8%B1%D8%A8%D9%87-%DA%86%D8%B4%D9%85-%D8%A7%D8%A8%DB%8C-%D9%88%D9%84%D8%A7%D8%BA%D8%B1-%D8%B3%DB%8C%D8%A7%D9%85%DB%8C-%D8%AF%D8%B1-%DB%8C%DA%A9-%D9%BE%D8%B3-%D8%B2%D9%85%DB%8C%D9%86%D9%87-%D8%8C-%D9%88%DA%A9%D8%AA%D9%88%D8%B1-%D8%B3%D9%81%DB%8C%D8%AF.jpg")
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.face_top_image).noFade().resize(100, 100)
.into(imageView);
Run Code Online (Sandbox Code Playgroud) 我有一个NavigationView有一些项目,每个项目都有标题和Drawable.
我的图像就像这样:
但是NavigationView为它添加蓝色色调.
如何从NavigationView编程中删除色彩?
这是我NavigationView的布局
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header"
app:menu="@menu/meny" />
Run Code Online (Sandbox Code Playgroud)
headerLayout有一个水平RecyclerView,有一些用户可以滚动它的项目.
我的问题是每当我想要滚动RecyclerView,drawerLayout即将关闭.
有没有什么办法来支持水平RecyclerView上Drawerlayout?
我想用Dagger 2和MVP模式.所以我有这个场景,每个View都有它自己的Component例如 MyFragment有这样的组件:
@PerFragment @Component(dependencies = ActivityComponent.class, modules = MyFragmentModule.class)
public interface MyFragmentComponent {
void inject(MyFragment fragment);
}
Run Code Online (Sandbox Code Playgroud)
在MyFragmentModule,我提供了一个演示者和一个将用于的模型MyFragment
@Module public class MyFragmentModule {
@Provides @PerFragment public MyPresenter providePresenter() {
return new MyPresenter();
}
@Provides @PerFragment public Model provideModel() {
return new Model();
}
}
Run Code Online (Sandbox Code Playgroud)
现在我正在注入组件MyFragment:
public class MyFragment extends Fragment{
@Inject MyPresenter presenter;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
component = DaggerMyFragmentComponent.builder()...build();
component.inject(this);
}
}
Run Code Online (Sandbox Code Playgroud)
也是MyPresenter这样的: …
但它们并不相同。角的笔划不同。
我使用 2 个分隔线Path来绘制顶部形状:第一个用于黄色背景:
private val paint = Paint().apply {
isAntiAlias = false // pass true does not make change
color = Color.YELLOW
style = Paint.Style.FILL_AND_STROKE // pass only FILL does not make change
}
Run Code Online (Sandbox Code Playgroud)
第二个是:
private val strokePaint = Paint().apply {
isAntiAlias = false // pass true does not make change
color = Color.BLACK
strokeWidth = 2.toPx().toFloat()
style = Paint.Style.STROKE
}
Run Code Online (Sandbox Code Playgroud)
在onDraw()函数中我用它们来绘制:
override fun onDraw(canvas: Canvas) {
drawPath()
canvas.drawPath(path, paint)
canvas.drawPath(path, strokePaint)
// …Run Code Online (Sandbox Code Playgroud) 我试图Usage_Stats_Service通过这个访问棒棒糖:
final UsageStatsManager usageStatsManager=(UsageStatsManager)this.getSystemService(Context.USAGE_STATS_SERVICE);Run Code Online (Sandbox Code Playgroud)
我可以去Context上课看看这个常量是如何存在的,但 Android Studio 一直说它不是一个有效的常量。
我也尝试使用文字字符串,但它似乎getSystemService有一个只接受@ServiceName常量的约束。
我已经花了将近 2 个小时的时间,却没有弄清楚发生了什么。欢迎任何帮助。
我有一个这样的界面:
interface MyInterface<V>{
}
Run Code Online (Sandbox Code Playgroud)
例如,我所有的带注释的类都以@MyAnnotation不同的方式实现了这个接口。
//first way
Class1 implement MyInterface<SomeClass>
//second way
AbstractClass<V> implement MyInterface<V>
Class2 extends AbstractClass<SomeClass>
//third way
ConcreteClass implement MyInterface<SomeClass>
Class3 extends ConcreteClass
Run Code Online (Sandbox Code Playgroud)
好吧,我有TypeElement1,2 和 3 类,我想找到类型变量的限定名称V。
我试过这个,但它返回V而不是SomeClass.
TypeElement class1 = ...
while(reachToMyInterface){
for (TypeMirror m : ((DeclaredType) class1.asType()).getTypeArguments()) {
print(m.toString()) // prints V
}
class1 = getItsSuperClass();
}
Run Code Online (Sandbox Code Playgroud)
编辑:这种方法也有同样的问题:
for (Element element : roundEnv.getElementsAnnotatedWith(Haha.class)) {
if (element instanceof TypeElement) {
TypeElement te = (TypeElement) element;
TypeElement …Run Code Online (Sandbox Code Playgroud) 我正在使用两个 LiveData 从我的服务器获取数据,并希望在两个 LiveData 完成后得到结果?
LiveData live1 = ...;
LiveData live2 = ...;
MutableLiveData live3 = ...;
live1.observe(this, value -> {
live3.postValue(value);
});
live2.observe(this, value -> {
live3.postValue(value);
});
live3.observe(this, value -> {
// TODO: Get both values from live1, live2
}
Run Code Online (Sandbox Code Playgroud)
我期望 live1 和 live2 的两个值
我使用的乔达库格式化字符串喜欢hh:mm am/pm到LocalTime我的Android应用程序,所以我用这个:
DateTimeFormat.forPattern("hh:mm a").parseLocalTime("6:30 AM");
Run Code Online (Sandbox Code Playgroud)
它工作正常,但当我改变我的手机语言(德国或西班牙语)时,它会抛出这个例外:
W/System.err? java.lang.IllegalArgumentException: Invalid format: "06:30 AM" is malformed at "AM"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?