我使用下面的代码,它不是渲染图形布局.显示错误为Exception raised during rendering: No tab known for tag null.
我怎么能解决这个问题?
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
Run Code Online (Sandbox Code Playgroud) 我一直在阅读Stackoverflow上的一些帖子,我没有找到一个好的解决方案,我想知道是否有可能检测到用户长时间按下电源按钮时试图关闭设备,我想知道你是否可以检测到该事件,并且让或者不显示出现的对话框(重启,关机等...)
我试过这个:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
Toast.makeText(MainActivity.this, event.getKeyCode(), Toast.LENGTH_SHORT).show();
return true;
}
Run Code Online (Sandbox Code Playgroud)
但它没有出现,它也应该作为一项服务工作,我的意思是应用程序可以打开或不打开显示吐司.
这就是我的方式 onCloseSystemDialog
//home or recent button
public void onCloseSystemDialogs(String reason) {
if ("globalactions".equals(reason)) {
Toast.makeText(PowerButtonService.this, "yaps", Toast.LENGTH_SHORT).show();
Intent i= new Intent(getBaseContext(), Demo.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(i);
//} else if ("homekey".equals(reason)) {
//home key pressed
//} else if ("recentapss".equals(reason)) {
// recent apps button clicked
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但只有当设备解锁时,设备被锁定时才会显示任何内容.
此外,我试图弄清楚如何在用户单击powerbutton时删除对话框我试过这个:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
Run Code Online (Sandbox Code Playgroud)
但如果我想再次展示它,我该怎么办呢?
官方缩放视图教程使用a AnimatorSet来放大View.随着视野的扩大,它会产生向下运动的错觉.之后,AnimatorSet只是向后重放以创建缩小的幻觉.
我需要实现的是与此完全相反的.我需要从扩展视图开始,然后将其缩小为一个向上移动的较小视图:
我似乎不能在示例中使用反转代码.该示例假定您首先放大视图并展开它,然后将其缩小回原始缩略图图标.
这是我到目前为止所尝试的内容.我的XML布局是
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#1999da">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:layout_gravity="center"
android:gravity="center">
<!-- The final shrunk image -->
<ImageView
android:id="@+id/thumb_button_1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginRight="1dp"
android:visibility="invisible"/>
</LinearLayout>
</LinearLayout>
<!-- The initial expanded image that needs to be shrunk -->
<ImageView
android:id="@+id/expanded_image"
android:layout_width="wrap_content"
android:layout_height="125dp"
android:layout_gravity="center"
android:src="@drawable/title_logo_expanded"
android:scaleType="centerCrop"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
这是执行缩小操作的方法.我基本上试图颠倒教程中的过程:
private void zoomImageFromThumbReverse(final View expandedImageView, int imageResId, final int duration) {
// If there's an animation in …Run Code Online (Sandbox Code Playgroud) java android android-animation objectanimator viewpropertyanimator
我想用电子邮件附加图像,该图像存储在其中/data/data/mypacke/file.png.如何以编程方式附加该图像文件?样本代码会是什么样的?
所以在这里我再次使用另一个Android Studio工具错误.我不认为之前有这个报道,我找不到任何帖子.
我试图通过单击以下按钮在Android Studio中打开设备监视器(DDMS):

每次我得到同样的错误.令人费解的是它出现了Eclipse错误,如图所示:

因此它告诉我在Android Studio SDK文件夹中打开一个日志文件.日志文件包含大量文本,但主要错误报告为:
!ENTRY org.eclipse.osgi 4 0 2015-05-27 09:40:53.091
!MESSAGE Application error
!STACK 1
java.io.IOException: The folder "C:\Users\JOHN%20SMITH\.android\monitor-workspace\.metadata" is read-only.
at org.eclipse.core.runtime.internal.adaptor.BasicLocation.lock(BasicLocation.java:206)
at org.eclipse.core.runtime.internal.adaptor.BasicLocation.set(BasicLocation.java:164)
at org.eclipse.core.runtime.internal.adaptor.BasicLocation.set(BasicLocation.java:137)
at com.android.ide.eclipse.monitor.MonitorApplication.start(MonitorApplication.java:53)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Run Code Online (Sandbox Code Playgroud)
为什么我无法从Android Studio打开DDMS,为什么在尝试从Android Studio打开DDMS时会抛出Eclipse错误?谁能指导我?有没有人以前见过这个错误?所有回复将不胜感激.
编辑:
正如指出的丹尼尔·纽金特在下面的意见,随Studio中的DDMS似乎正好,正好一样的一个在Eclipse.不知道这是否是问题的线索.为了记录,我确实在我的PC上安装了Eclipse来维护一些遗留代码.
编辑2:
我试图在Android手机上使用本机电子邮件客户端发送电子邮件.
我试过以下方法为邮件添加附件...
方法 - 1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/abc.jpg"));
Run Code Online (Sandbox Code Playgroud)
方法2
将图像作为正文内容发送---
sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG**SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"**alt = \"**pleaseview this
image\"/></b></BODY></HTML>");
Run Code Online (Sandbox Code Playgroud)
我可以手动成功附加图像,但当我尝试附加并以编程方式发送它时,邮件是在没有附件的情况下发送的.
如果有办法使用电子邮件客户端以编程方式发送附件,请告诉我
我正在尝试创建一个Dialog显示类似ACTION_PICK_WIFI_NETWORK但不是Android Settings / WiFi打开它的东西Dialog,如果它可能用户可以连接到任何可用的网络Dialog.我目前在Android上打开了Dialog一个List可用的Wi-Fi网络,但这List与Android Settings / WiFi我的问题不一样,为什么我要问是否可以ACTION_PICK_WIFI_NETWORK在对话框中打开它并使用它.如果不可能我怎么能连接到网络点击Item我Dialog的WiFi可用?
我有一个 BroadcastReceiver()
wifiReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context c, Intent intent){
if(mWifiManager != null) {
List<ScanResult> results = mWifiManager.getScanResults();
showWifiListDialog(results);
}
}
};
Run Code Online (Sandbox Code Playgroud)
一个 RegisterReceiver()
registerReceiver(wifiReceiver,new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
Run Code Online (Sandbox Code Playgroud)
这是做的方法 WifiScan
private void startWifiScans() {
mWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
mWifiManager.startScan();
}
Run Code Online (Sandbox Code Playgroud)
这就是Dialog显示的简单SCAN_RESULTS_AVAILABLE_ACTION
private void showWifiListDialog(List<ScanResult> results) …Run Code Online (Sandbox Code Playgroud) 每次显示时,我都尝试boolean在类中使用 a 来做一些事情。FragmentFragment
我的应用程序启动,打开 ,FirstFragment并且boolean第一次总是true,然后我有一个if子句检查其值:
if (FirstTime) {
FirstTime = false;
} else {
// Other stuff here, cause it's not true.
}
Run Code Online (Sandbox Code Playgroud)
然后,在第一次,什么时候FirstTime,true我做了一些事情,比如去另一个地方Fragment。当我返回Fragment1并在我的 上时onCreate(),我也会做同样的事情。总是true,看起来很清爽什么的。
然后我认为这可能是 的问题Fragment,每次我按 时Fragment1,它都会重新启动或发生其他情况。然后,我在我的中添加了 getter 和 setter MainActivity:
public Boolean getFirstTime() {
return FirstTime;
}
public void setFirstTime(Boolean FirstTime) {
this.FirstTime = FirstTime;
}
Run Code Online (Sandbox Code Playgroud)
从一开始,这是真的,然后,我将代码更改Fragment1 …
java android sharedpreferences android-lifecycle android-fragments