public abstract class MainActivity extends AppCompatActivity {
private static WebView web;
private WebView mWebView;
private java.lang.String url;
Boolean isInternetPresent = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ConnectivityManager manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo i = manager.getActiveNetworkInfo();
boolean hasConnect = (i != null && i.isConnected() && i.isAvailable());
if (hasConnect) {
} else {
}
Timer repeatTask = new Timer();
repeatTask.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
mWebView.loadUrl("http://www.smedk.ru/wp-content/uploads/files/education/rasp/1151.htm");
}
});
}
}, …Run Code Online (Sandbox Code Playgroud) 更新后 com.android.support.constraint:constraint-layout:1.1.0
约束布局崩溃说:
约束布局的所有子项都应该具有使用约束集的id
我已经为所有视图设置了ID,即使它崩溃了.
java.lang.RuntimeException: All children of ConstraintLayout must have ids to use ConstraintSet at android.support.constraint.ConstraintSet.clone(ConstraintSet.java:687) at com.zoho.notebook.views.SettingsViewNavBar.showNoteSettingsView(SettingsViewNavBar.java:594) at com.zoho.notebook.views.SettingsViewNavBar.onClick(SettingsViewNavBar.java:303)
Run Code Online (Sandbox Code Playgroud)
此问题仅发生在平板电脑设备上.
我正在看Netflix应用程序和他们的滚动行为.我想做同样但不知道从哪里开始.我知道如何重写LayoutManager了RecyclerView(虽然我不保存,作为最后的手段).是否有更简单的方法来使用RowPresenter控制滚动速度?
我有以下代码 Activity
@Override
public void onPause() {
super.onPause();
if (isFinishing()) {
final LiveData<StickyNoteConfig> stickyNoteConfigLiveData = StickyNoteConfigRepository.INSTANCE.getStickyNoteConfig(mAppWidgetId);
stickyNoteConfigLiveData.removeObservers(this);
stickyNoteConfigLiveData.observe(this, stickyNoteConfig -> {
// Weird, I still can receive call back.
// I thought "this" is no longer active?
});
}
}
Run Code Online (Sandbox Code Playgroud)
我感到困惑的Observer是,虽然this活动已经处于onPause状态,但仍然被触发了?根据https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.State#STARTED
为LifecycleOwner启动状态.对于活动,在两种情况下达到此状态:
Run Code Online (Sandbox Code Playgroud)after onStart call; right before onPause call.
我可以知道为什么会这样吗?
当我更新android studio 3.2.0到3.2.1.我使用数据绑定,当运行项目时显示我这样的错误,如果我错了请建议我.
Could not find com.android.databinding:compiler:3.2.1.
Searched in the following locations:
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
Run Code Online (Sandbox Code Playgroud)
要求:项目:app
project.gradle
buildscript {
ext{
kotlin_version = '1.2.71'
gradle_version = '3.2.1'
}
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
dependencies {
classpath "com.android.tools.build:gradle:3.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven { url …Run Code Online (Sandbox Code Playgroud) new Date().toLocaleDateString('en-US'); // "?8?/?17?/?2018"new Date("8/17/2018") //valid date new Date(new Date().toLocaleDateString('en-US')) // Invalid Date我试图创造date,local date
string (see screenshot)但它没有工作IE11 only.它可以正常使用date string.
我知道有问题"" double quotes但却无法使其正常工作.
有什么建议吗?
我有一个简单的NanoHTTPD服务器作为前台服务运行.
当向服务器发出新请求时,我在使用新内容更新通知时遇到问题.
前台服务启动并显示通知.没问题.但是以后无法更新它们.
文件结构
- Mainactivity
- NanoServer (服务器实现)
- NanoService (前台服务类)
- NotificationProvider (处理通知的单独类)
NanoServer.java
public Context context = getContext();
public NotificationProvider notificationProvider;
public NanoServer(int port) {
super(8089);
}
@Override
public Response serve(String uri, Method method,
Map<String, String> header, Map<String, String> parameters,
Map<String, String> files) {
String answer = "";
String msg;
// doesnt work with the context. something wrong here I guess????
notificationProvider = new NotificationProvider();
notificationProvider.setNotification(context, "Title", uri, 0);
FileInputStream fis = null;
try {
fis = …Run Code Online (Sandbox Code Playgroud) java android android-notifications nanohttpd foreground-service
场景如下,我有一个包含片段的ViewPager,这些片段中的每一个都有一些需要确认的动作.
我继续创建一个DialogFragment,目标是知道如何处理结果的片段,但是在用户确认或拒绝对话之前可能会重新创建片段.
我可以将一个lambda或其他形式的监听器传递给对话框,然后在用户确认对话框时调用它,但问题是如果设备随后被旋转,则lambda会丢失,因为它不能持久化捆绑......
我能想到的唯一方法是将一些UUID分配给对话框,并将应用程序中的UUID连接到lambda,lambda保存在应用程序内的Map上,但这似乎是非常草率的解决方案..
我尝试在线搜索现有的解决方案,例如材料对话框库样本,但大多数情况似乎都忽略了旋转对话框,但这似乎也是一个草率的解决方案,因为对话框可能是较长流程的一部分,例如如
请求购买 - >取消 - >显示带有解释的对话框 - >如果用户想要再次购买
如果我们简单地忽略旋转对话框,那么流动状态将会丢失
我最近使用了https://material.io/tools/color/上的材料调色板生成器来生成调色板。
如您所见,该工具是 Material.io 上的官方工具。它生成了几种颜色 - 主要颜色和次要颜色,包括每种颜色的两种变体。这导致我在我的colors.xml文件中创建了这样的东西。
<!-- Color palette -->
<!-- ... -->
<!-- Colors by usage -->
<color name="colorPrimary">@color/black</color>
<color name="colorPrimaryDark">@color/blackDark</color>
<color name="colorPrimaryLight">@color/gray</color>
<color name="colorSecondary">@color/red</color>
<color name="colorSecondaryDark">@color/maroon</color>
<color name="colorSecondaryLight">@color/redLight</color>
<color name="colorTextOnPrimary">@color/white</color>
<color name="colorTextOnSecondary">@color/white</color>
Run Code Online (Sandbox Code Playgroud)
但是,如何在我的主题中应用这些颜色?Android 支持材料 (AppCompat) 主题只需要/允许三种颜色 - 主要、次要和重音。我应该使用另一个主题来应用这些属性吗?或者我只是在这里做错了什么?
我想避免在这里创建一个全新的主题,并且必须为我可能想要使用的每个组件手动设置颜色。
android android-theme android-styles material-design android-palette
我在WebView里面RecyclerView.为了获得平滑的滚动体验,当用户滚动时,RecyclerView将负责滚动(WebView不应滚动)当我只有一个触摸点并且正在垂直移动(向上和向下滚动)时我调用getParent().requestDisallowInterceptTouchEvent(false);内部webview#onTouchEvent(event).
private void handleSingleFingerTouch(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
x1 = ev.getX();
y1 = ev.getY();
break;
case MotionEvent.ACTION_MOVE:
x2 = ev.getX();
y2 = ev.getY();
// -ve param for canScrollHorizontally is to check scroll left. +ve otherwise
if (Math.abs(x1 - x2) >= Math.abs(y1 - y2)
&& canScrollHorizontally((int) (x1 - x2))) {
// scrolling horizontally. Retain the touch inside the webView.
getParent().requestDisallowInterceptTouchEvent(true);
} else {
// scrolling vertically. …Run Code Online (Sandbox Code Playgroud) android ontouchlistener android-webview android-recyclerview android-touch-event
android ×8
android-architecture-components ×1
android-tv ×1
date ×1
dialog ×1
java ×1
javascript ×1
leanback ×1
nanohttpd ×1
webview ×1