我试图将Base64String转换为需要在本地保存的图像.
目前,我的代码能够保存图像,但是当我打开保存的图像时,它会显示"无效图像".
码:
try
{
using (var imageFile = new StreamWriter(filePath))
{
imageFile.Write(resizeImage.Content);
imageFile.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
的Content
是一个string
其中包含的Base64字符串对象.
当我尝试构建Windows Phone应用程序时,我在PC上收到此错误消息:
Xap packaging failed. Object reference not set to an instance of an object
Run Code Online (Sandbox Code Playgroud)
我正在使用Dropbox.在我的笔记本电脑上,它工作得很好,我可以调试等...但在我的电脑上,我不能.
我尝试了很多东西,比如:
到目前为止,没有任何帮助.
知道如何解决这个问题吗?
silverlight xap visual-studio windows-phone-7 windows-phone-7.1
很简单,我怎么说如果一个给定TextView
包含一个特定的字符串Espresso
.
相当于: myStrings.contains("Subby");
我试图翻转和ImageView
垂直,但它不会工作.
Java的:
public static void flipImageVertically(final Bitmap bmp, final ImageView imageView) {
final Matrix matrix = new Matrix();
matrix.preScale(1.0f, -1.0f);
imageView.setImageBitmap(Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true));
}
Run Code Online (Sandbox Code Playgroud)
XML:
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/red" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这ImageView
根本不是在翻转.
谁知道为什么?
我有一个场景,我必须使用相同的BaseUrl调用API,例如www.myAPI.com
但是有不同的baseUrl
.
我有一个实例Retrofit 2
是通过以下方式构建的Builder
:
return new Retrofit.Builder().baseUrl(FlavourConstants.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).client(okHttpClient).build();
该FlavourConstants.BASE_URL
如下所示:
public static final String BASE_URL = "http://myApi.development:5000/api/v1/";
对于某些人来说WebRequests
,我必须调用相同的API,但在其他API上,我必须从完全不同的方式调用它BaseUrl
.如何Retrofit
在运行时更改实例以指向不同的URL?
该Retrofit
实例没有.setBaseUrl
或setter
通过a构建的任何类似内容Builder
.
有任何想法吗?
我试图PUT
在我的Retrofit
实例上调用一个方法:
Response<UpdateUserProfileResponse> response = App.getService().updateUserProfile(//A good 26 parameters).execute();
Run Code Online (Sandbox Code Playgroud)
其中的参数updateUserProfile()
是String,Boolean和one的混合List<MyObject>
.当我调用此方法时,我收到以下错误:
Throwing new exception 'length=238; index=1366' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=238; index=1366
06-28 21:53:12.458 3928-6610/com.subby.development A/art: art/runtime/thread.cc:1329] at retrofit2.Response
Run Code Online (Sandbox Code Playgroud)
更新
我发现了这个问题.有两个RealmList<BackgroundString>
导致问题.当我评估两个RealmLists时,我得到:
Unable to evaluate the expression method threw 'java.lang.IllegalStateException' exception.
我希望创建一个简单的布局,如下所示.
有人可以告诉我如何实现这一目标吗?请原谅"坦率",我来自C#背景,因此开发WEB UI对我来说有点令人生畏.
更新: 我正在玩耍和CSS而不是生产我想要的东西.
我正在做以下事情:
if (File.Exists(filePath))
{
string base64 = File.ReadAllText(filePath);
return new ImageContentDTO
{
ImageContentGuid = imageContentGuid,
Base64Data = base64
};
}
Run Code Online (Sandbox Code Playgroud)
这完全没问题.我想问的是,在我阅读完文件后,我是否需要关闭文件或类似内容.如果是这样,怎么样?
目标:
1)使状态栏透明 - 完成
2)充分利用BottomNavigationView
和Navbar
相同的颜色.- 差不多完成了
问题
通过在我的代码中添加以下代码Activity
,状态栏变为透明.但是,BottomNavigationView
落在了下面NavBar
.如果我删除这行代码,则StatusBar
不再是透明的.你觉得我在这痛苦吗?此外......如何让布局的TOP位于状态栏下方?
活动中的代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
Run Code Online (Sandbox Code Playgroud)
活动XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<com.custom.app.view.ClickableViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/tab_layout" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/custom_black"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/bottom_navigation_main" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
Style.xml
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item …
Run Code Online (Sandbox Code Playgroud) 我在ASP.NET MVC的Twitter Bootstrap中使用Modal,允许用户上传Image.
我正在使用文件上传控件,可以在这里找到:https://github.com/blueimp/jQuery-File-Upload
以下是显示文件上传控件的代码片段:
<div class="modal-body">
<form id="imageUpload" action="@Url.Content("~/Listing/ReturnBase64Data")" method="POST" enctype="multipart/form-data">
@Html.HiddenFor(m => m.ListingGuid)
<div class="fileupload-buttonbar">
<div class="progressbar fileupload-progressbar" id="progressbar">
</div>
<div class="fileinput-button">Upload Image
<input type="file" id="fileupload" name="image"/>
</div>
</div>
@if (Model.SelectedImage == null)
{
<div id="show_image">
</div>
}
else
{
<div id="show_image">
<img style="height:200px ! important;" src="data:image/png;base64, @Model.SelectedImage.Content"/>
</div>
}
<div id="show_error" >
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
</form>
标签后面有更多代码,但这是主要部分.
以下显示文件上载控件和旁边的字母"N".字母N实际上是一个表示"没有选择文件"的字符串.但由于某种原因,似乎有一些东西与整个控件重叠.
有谁知道我哪里出错了?