这是我的情景
我正在这样做 ItemDecoration
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int totalHeight = parent.getHeight();
int viewHeight = getResources().getDimensionPixelOffset(R.dimen.breadcrumb_btn_height);
int padding = (totalHeight - viewHeight) / 2;
//to position view on middle
if (view.getTag() instanceof Integer) {
int position = (int) view.getTag();
if (position == 0) {
//first position
outRect.set(padding, padding, 0, padding);
} else if (position == linearLayoutManager.getItemCount() - 1) {
//last position
outRect.set(0, padding, padding, padding);
} else { …Run Code Online (Sandbox Code Playgroud)我已经使用以下选项来创建单词大写的每个起始字母
<EditText
android:inputType="text|textCapWords"/>
Run Code Online (Sandbox Code Playgroud)
键入用户时键盘上的选项可以更改字母大小写,即使用此选项的用户可以轻松键入lowercase字母.
此外,我希望我的文字EditText采用这种格式
Each Starting Letter Of A Word Must Be In Uppercase And All Other Letter Of The Word Be In Lowercase.
意思是,当用户输入时
each StArting LeTTer of a word musT be in uppercase and all other leTTer of the word be in lowercase
,它将自动转换为以上格式.
我尝试过使用TextWatcher并string.split(\\s+)获取所有单词,然后使每个单词都遵循上述格式.但我总是得到错误.所以,如果有任何解决方案,那就太棒了.我希望这种方式有效InputFilter.AllCaps.
到目前为止这是我的代码
private void changeToUpperCase(String inputString) {
if (inputString != null && inputString.trim().length() > 0) {
// businessName.addTextChangedListener(null);
String[] splitString = inputString.split("\\s+"); …Run Code Online (Sandbox Code Playgroud) 当我们定义具有以下格式的类时
public class Field {
@SerializedName("name")
public String name;
@SerializedName("category")
public String category;
}
Run Code Online (Sandbox Code Playgroud)
对于JsonObject内容
{
"name" : "string",
"category" : "string",
}
Run Code Online (Sandbox Code Playgroud)
并Gson用于解析内容
Field field = new GsonBuilder().create().fromJson(
content, Field.class);
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是我们可以用它Gson来获得@Serialized名称.在这种情况下,我想知道什么@Serialized名称用于field.name,这是name和field.category它category.
根据@Sotirios Delimanolis的建议,使用Reflection我们可以得到这个Serialized名字
java.lang.reflect.Field fields = Field.class.getDeclaredField("name");
SerializedName sName =fields.getAnnotation(SerializedName.class);
System.out.println(sName.value());
Run Code Online (Sandbox Code Playgroud) 我有一个表标签
<table width="100%" align="center"/>
Run Code Online (Sandbox Code Playgroud)
到目前为止Jsoup提供
Document document =Jsoup.parse(htmlString);
document.select("table[width=100%],table[align=center]");
Run Code Online (Sandbox Code Playgroud)
这是OR命令,即如果任何一个匹配则填充元素.为了选择宽度= 100%且对齐=中心的表格,我做了以下操作
Elements element =document.select("table[align=center]");
element =element.select("table[width=100%]");
Run Code Online (Sandbox Code Playgroud)
所以我要问的是,就像这个OR组合一样
document.select("table[width=100%],table[align=center]");
Run Code Online (Sandbox Code Playgroud)
是否有任何AND组合选择器,即宽度= 100%且对齐=中心的表格.提前致谢
这是我的情况
productFlavors {
paid {
applicationId "com.paid.app"
}
free {
applicationId "com.free.app"
}
}
Run Code Online (Sandbox Code Playgroud)
并且在paid风味上我需要与下面相比main或者free如下所述的不同的发射器活动
main/AndroidManifest.xml
<activity
android:name=".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>
paid/AndroidManifest.xml
<activity
android:name=".SecondMainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
当我开始在paid构建变体中安装应用程序时,它总是安装两个应用程序,即免费和付费但具有相同的应用程序名称.当我卸载任何一个时,应用程序都会被卸载.不仅应该paid变种构建付费应用程序和free变体构建一个免费的应用程序?以下是我的工作环境
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
Android Studio 1.4 beta 2
Run Code Online (Sandbox Code Playgroud) 我是Android开发的新手,这个webview和webview客户端正在杀了我.这是我的情景:
我要做的是模拟浏览器的工作过程,即用户登录时,他/她自动被授予添加Facebook评论的权限.
我的问题:
我不知道如何从浏览器获取所有身份验证并将其重定向回我的应用程序webview.我想要的是在我的应用程序webview中执行所有过程,而不是去默认浏览器.
我检查了所有堆栈溢出问题,他们中的大多数建议使用Facebook连接和Facebook android SDK等开源Facebook插件.而且我得到了一些信息CookieManager,CookieSyncManager,WebViewClient,WebChromeClient但我不能对我的问题落实.而我发现的最接近的是:
如何在android webview中使用确认来处理facebook
所以,如果你能指出我正确的方向,我会很高兴.我仍然试图了解如何在webview上进行所有操作,如果有任何问题,我肯定会发布.
提前致谢
更新
我只能实现facebook登录但无法实现AOL,Hotmail并Yahoo登录.对于facebook登录,只需创建一个自定义WebViewClient和方法shouldOverrideUrlLoading
if(url.contains("https://www.facebook.com/connect/window_comm.php")){
webView.clearHistory();
webView.loadUrl(remoteUrl);
}
return false;
Run Code Online (Sandbox Code Playgroud)
为了允许多次登录,我已经实现了以下技术,但它不起作用
if(url.contains("https://www.facebook.com/connect/window_comm.php")){
String cookieString = cookieManager.getCookie("facebook.com");
if(cookieString != null){
cookieManager.setCookie("remoteUrldomain.com", cookieString);
CookieSyncManager.getInstance().sync();
webView.clearHistory();
webView.loadUrl(remoteUrl);
}
}
return false;
Run Code Online (Sandbox Code Playgroud)
我仍然在尽力找到解决办法,任何人都会指引我正确的方向,我将感激不尽.提前致谢
我正在使用Android Volley库发送POST请求.并POST请求
Content-Type:application/jsonJson String但无论如何,我要改变它Volley Request Header,它总是被设定为Content-Type:text/html.这给了我400 Bad Request.这是我的课程POST请求Volley
public class GsonRequest<T> extends Request<T> {
private final Class<T> clazz;
private final Map<String, String> headers;
private final Listener<T> listener;
private Map<String, String> postParams;
private String postString = null;
/**
* Make a GET request and return a parsed object from JSON.
*
* @param url
* URL of the request to make
* …Run Code Online (Sandbox Code Playgroud) 我有一个接口类
public interface AsyncTaskExecuteCommand {
public Object executeCommand(String jsonLocation) throws IOException,JSONException;
}
Run Code Online (Sandbox Code Playgroud)
我有一个存储此接口实例的HashMap
public static HashMap<String,AsyncTaskExecuteCommand> executeCommandHashMap
executeCommandHashMap.put(COMMAND_CORE_FIELD_FETCH, new AsyncTaskExecuteCommand() {
@Override
public Object executeCommand(String jsonLocation) throws IOException, JSONException{
//return some thing
}
});
executeCommandHashMap.put(COMMAND_REGISTER_FIELD_FETCH, new AsyncTaskExecuteCommand() {
@Override
public Object executeCommand(String jsonLocation) throws IOException,
JSONException {
//return some thing
}
});
Run Code Online (Sandbox Code Playgroud)
我的AsyncTask名为GeneralAsyncTask包含
doInBackground(){
AsyncTaskExecuteCommand asyncTaskExecuteCommand = executeCommandHashMap.get(params[0]);
return asyncTaskExecuteCommand.executeCommand(params[1]);
}
Run Code Online (Sandbox Code Playgroud)
而这个AsyncTask被调用
new GeneralAsyncTask().execute(COMMAND_REGISTER_FIELD_FETCH,"http://something");
Run Code Online (Sandbox Code Playgroud)
我这样做是因为我的AsyncTask的一般结构保持不变,即它做了一些方法执行并返回一些值.只有方法执行类型和返回值会有所不同.如果我不实现传递接口到异步任务,我最终创建了许多AsyncTask类.那么,这种方法是否可以解决我的问题?