我有一个这样的字符串:+33123456789(法国电话号码).我想在不知道国家的情况下提取国家代码(+33).例如,如果我有来自其他国家的另一部电话,它应该可以工作.我使用谷歌库https://code.google.com/p/libphonenumber/.
如果我知道这个国家,很酷我可以找到国家代码:
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
int countryCode = phoneUtil.getCountryCodeForRegion(locale.getCountry());
Run Code Online (Sandbox Code Playgroud)
但我找不到解析字符串而不知道国家的方法.
我的DialogFragment有问题.所以要创建我的视图,我使用android博客上描述的方法.这是我的DialogFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View myLayout = inflater.inflate(R.layout.dialog_connect, null);
edit = (EditText) myLayout.findViewById(R.id.password_edit);
edit.requestFocus();
getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return myLayout;
}
Run Code Online (Sandbox Code Playgroud)
如果我使用onCreateView(),它可以工作,但我想创建一个AlterDialog并执行此操作,我有以下代码:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
callback.onYesConnectClick(edit.getText().toString());
}
})
.setNegativeButton(R.string.refuse, new DialogInterface.OnClickListener() …
Run Code Online (Sandbox Code Playgroud) 我有一个android studio adn gradle导入appcompat-v7的问题.
所以这是我在src目录中的build.gradle
apply plugin: 'android'
apply plugin: 'android-apt'
def AAVersion = '3.0.1'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
packageName "com.test"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
apt {
arguments {
resourcePackageName android.defaultConfig.packageName
androidManifestFile variant.processResources.manifestFile
}
}
dependencies {
// You must install or update the Support Repository through the SDK manager to use this dependency.
// The Support Repository (separate …
Run Code Online (Sandbox Code Playgroud) 谷歌正式发布了他们的博客上提到的杰克和吉尔http://android-developers.blogspot.fr/2014/12/hello-world-meet-our-new-experimental.html
但是,如果我使用以下属性:
defaultConfig {
applicationId 'xxx'
minSdkVersion 10
targetSdkVersion 19
versionCode 162
versionName 'xxx'
// Enabling multidex support.
multiDexEnabled true
testInstrumentationRunner "android.support.multidex.MultiDexTestRunner"
manifestPlaceholders = [ cappId:"xxx",cappLog:"false" ]
useJack = true
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Error:Cannot get property 'destinationDir' on null object
Run Code Online (Sandbox Code Playgroud)
如果我评论使用Jack属性我没有问题
我知道这是一个实验工具,但你知道我该如何解决这个问题?
当我使用retrofit 1.4.1和okhttp 1.3.0在WS上激活gzip时,我遇到了问题.
RequestInterceptor requestInterceptor = new RequestInterceptor() {
@Override
public void intercept(RequestFacade request) {
request.addHeader("content-type", "application/json");
request.addHeader("accept-encoding", "gzip"); // Here is the problem
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(Constants.HOST)
.setLogLevel(RestAdapter.LogLevel.FULL)
.setRequestInterceptor(requestInterceptor)
.build();
Run Code Online (Sandbox Code Playgroud)
如果我评论以下行request.addHeader("accept-encoding", "gzip");
没有问题,但如果激活gzip,我会收到一个错误(我的请求落入failure
).
这是我的logcat request.addHeader("accept-encoding", "gzip");
1326 Retrofit D : HTTP/1.1 200 OK
1326 Retrofit D Cache-Control: public, max-age=600
1326 Retrofit D Content-Encoding: gzip
1326 Retrofit D Content-Length: 254
1326 Retrofit D Content-Type: application/json
1326 Retrofit D Date: Wed, 05 Feb 2014 …
Run Code Online (Sandbox Code Playgroud) 事实上,我搜索的方式是模仿FAB的收件箱.当用户按下红色按钮时,应显示opac视图和菜单.由于图像更有意义,请参见下图
我知道它存在这个很棒的库(https://github.com/futuresimple/android-floating-action-button),通过这个库,我可以显示浮动动作菜单.但我的问题是显示白色背景(不透明度).我没有找到解决问题的解决方案......
Thx提前
我刚刚将我的android gradle插件从0.12更新到0.13.此外,我已经下载了gradle 2.1.然后,我尝试使用android studio 0.8.9测试版但是根据http://tools.android.com/tech-docs/new-build-system/version-compatibility我必须至少使用android studio 0.8.11(金丝雀)渠道).所以我已经更新了我的android工作室,但我仍然有问题.
现在,我必须使用gradle 1.10和android gradle插件0.12.+才能工作
来自AS的错误
Error:No such property: projectDependencies for class: com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated
编辑:
这是我的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
// works with 0.12.+ (not with 0.13.+)
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// The latest version of the android-apt plugin
classpath …
Run Code Online (Sandbox Code Playgroud) 我在我的Android代码中添加了一些用户属性,例如:(https://firebase.google.com/docs/analytics/android/properties)
mFirebaseAnalytics.setUserProperty("easy_account_connected", "true");
然后,我检查了调试视图,没有出现任何内容,而如果有一个断点,我的代码停止在此指令上.我无法理解,在我的代码中有其他地方我们可以找到这些属性,有时它可以工作(我在调试视图中看到它),有时,没有.
这是正常的吗?
我在firebase网站上找不到任何可以告诉我调试视图不完美但数据被正确保存的内容......
https://firebase.google.com/docs/analytics/debugview#seconds_stream
在adbitx的帮助下,我发现用户属性随事件一起发送,因此我创建了一个新的用例.2个事件(登录/注销)和一个用户属性(easy_account_connected).在登录案例中,我发送:
mFirebaseAnalytics.setUserProperty("easy_account_connected", "true");
mFirebaseAnalytics.logEvent("login", null);
Run Code Online (Sandbox Code Playgroud)
在注销的情况下,我发送:
mFirebaseAnalytics.setUserProperty("easy_account_connected", "false");
mFirebaseAnalytics.logEvent("logout", null);
Run Code Online (Sandbox Code Playgroud)
登录工作,而注销不...
我做了一个Android应用程序,我想在标记上方(或下方)添加文本.我发现此链接如何在Google地图上的标记上方添加文字?但这是谷歌地图的旧api.所以我想知道我们是否可以用新api做同样的事情?
我曾尝试使用此代码执行此操作:
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.pin_favoris).copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(bm);
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(25);
canvas.drawText("Favoris", 0, bm.getHeight(), paint); // paint defines the text color, stroke width, size
BitmapDrawable draw = new BitmapDrawable(getResources(), bm);
Bitmap drawBmp = draw.getBitmap();
// gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(fakeMarker, 15));
gMap.addMarker(new MarkerOptions()
.position(fakeMarker)
.icon(BitmapDescriptorFactory.fromBitmap(drawBmp))
);
Run Code Online (Sandbox Code Playgroud)
但文本只能显示在位图中(不在上方/下方)!
我知道它存在很多问题,但我不明白为什么我的下面的代码不再起作用了
这是我的代码:
private void init() {
webview.setWebViewClient(new FormWebViewClient());
webview.postUrl(url, EncodingUtils.getBytes(data, "BASE64"));
}
private class FormWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
// progressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LOGD(TAG, "Url : " + url);
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
view.loadUrl("javascript:" +"document.getElementsByClassName('my_class_name')[0].value = '" + myValue + "';" +
}
}
Run Code Online (Sandbox Code Playgroud)
我的原始webview被覆盖,它只显示myValue
在页面中而不是大量的信息.
如果有人知道为什么我有这种行为......
谢谢
编辑:
和HTML的一部分
<input type="text" …
Run Code Online (Sandbox Code Playgroud) 我知道有很多问题DatePickerDialog
在这篇帖子中解释Jelly Bean DatePickerDialog ---有没有办法取消?但我的问题是,我想只显示确认按钮,而不是两个按钮.我使用DatePickerDialog
的DialogFragment
是这样的:
public class DateDialog extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// set up mindate
minYear = year;
minMonth = month;
minDay = day;
// Create a new custom instance of DatePickerDialog and return …
Run Code Online (Sandbox Code Playgroud)