我想知道如何在更改手机方向时修改视图.例如,当你按住手机"正常方式"时,我的应用程序工作正常,但当你将它移动到横向位置时,应用程序外观变得丑陋: - 如何确保壁纸不会与手机一起"转动" ,这是我的布局代码:文件名:list-event.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<ListView android:id="@android:id/list"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="@drawable/fon2"></ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
你可以看到它只是一个简单的列表,但我希望背景保持不变.我为布局和布局添加了相同的内容 - 我只是将同一个文件列为list_event,但我认为我需要为背景图像添加一些命令,以便以不同的方式进行定向.我希望你提前了解我写的内容
我想使用Regex从html文件中提取一些文本.我正在学习正则表达式,但我仍然无法理解它.我有一个代码,提取所有包含在下面的文本<body>,</body>这里是:
public class Harn2 {
public static void main(String[] args) throws IOException{
String toMatch=readFile();
//Pattern pattern=Pattern.compile(".*?<body.*?>(.*?)</body>.*?"); this one works fine
Pattern pattern=Pattern.compile(".*?<table class=\"claroTable\".*?>(.*?)</table>.*?"); //I want this one to work
Matcher matcher=pattern.matcher(toMatch);
if(matcher.matches()) {
System.out.println(matcher.group(1));
}
}
private static String readFile() {
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("user.html");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in)); …Run Code Online (Sandbox Code Playgroud) 我想创建void指针数组.
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
int main(){
void * A[3];
void * D[3];
void * F[2];
void * G[4];
void * H[4];
void * J[3];
void * K[5];
void * L[4];
void * M[5];
A={D, H, K};
D ={A, G, H};
F ={K, L};
G={D, H, J, M};
H={A, G, L, M};
J={G, L, M};
K={A, F, H, L, M};
L={F, J, K, M};
M={G, H, J, K, L};
return 0;
}
Run Code Online (Sandbox Code Playgroud)
问题是代码不会编译它说:"{token"之前的预期表达式
怎么了?我正在使用这些指针因为它们的值无关紧要我只想让它们指向对方.例如,M必须指向G,H,J,K和L.
非常感谢您提供任何帮助或建议,
您好我正在使用AnimatorSet和ValueAnimator将多个动画应用于视图.
当用户触摸视图时,将连续的动画应用于视图.当用户在视图上移动手指时,我这样做是为了"缩放效果".
该视图是一个自定义库.
这是动画的代码:
private void createAnim(final View v) {
animating = true;
if (D)
Log.i(TAG, "sarting animation");
try {
v.clearAnimation();
v.getAnimation().reset();
} catch (Exception e) {
}
set = new AnimatorSet();
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (D)
Log.i(TAG, "Animation ended");
animating = false;
}
@Override
public void onAnimationCancel(Animator animation) {
animating = false;
if (D)
Log.i(TAG, "Animation cancelled");
}
}); …Run Code Online (Sandbox Code Playgroud) 我有一个功能,我只希望仅在满足某些条件时才可用,因此我具有以下活动别名:
<activity-alias android:name="share-files-text"
android:targetActivity=".MyActivity"
android:exported="true"
android:enabled="false">
<intent-filter android:label="@string/open_with">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/pdf" />
<data android:mimeType="image/*" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity-alias>
Run Code Online (Sandbox Code Playgroud)
活动后,我将使用以下代码启用该组件
String packageName = getPackageName();
ComponentName componentWithTextFiles = new ComponentName(packageName, "share-files-text");
ComponentName componentWithoutTextFiles = new ComponentName(packageName, "share-files");
if(DebugAndTestSettings.ENABLE_TEXT_SLIDE){
getPackageManager().setComponentEnabledSetting(componentWithTextFiles, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
getPackageManager().setComponentEnabledSetting(componentWithoutTextFiles, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
} else {
getPackageManager().setComponentEnabledSetting(componentWithTextFiles, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
getPackageManager().setComponentEnabledSetting(componentWithoutTextFiles, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
}
Run Code Online (Sandbox Code Playgroud)
问题是崩溃说软件包blabla不包含名为share-files-text的活动,如何使用别名来禁用/启用此元素?谢谢
编辑:我从这篇文章中得到了这个主意: Android:我可以以编程方式启用/禁用活动的意图过滤器吗?
我想在我的java程序中打开一个文件,但我无法让它工作.我希望我的程序可以在所有平台上运行,尤其是在ubuntu中.
这是我有的:
private void openFileChoser() {
JFileChooser chooser = new JFileChooser(".");
int returnVal = chooser.showOpenDialog(getParent());
if(returnVal == JFileChooser.APPROVE_OPTION) {
openFile(chooser.getSelectedFile().getAbsolutePath());
} else {
System.out.println("Aucun fichier choisi");
}
}
/***
* ouverture du fichier :
* @param name
*/
private void openFile(String name) {
System.out.println("Ouverture du fichier: " +
name);
try {
Runtime.getRuntime().exec(new String[]{name});
//Desktop.getDesktop().open(new File(name)); //doesn't work on ubuntu 13.04
} catch (Exception e) {
System.err.println("Erreur d'ouverture du fichier : "+name);
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我试图打开文件:/home/user/IdeaProjects/androidresourcehelper/test.xls
我得到了例外:
java.io.IOException: Cannot run program …Run Code Online (Sandbox Code Playgroud) 嗨我对xcode 4.2内存管理系统有疑问.我在这里读到,在xcode 4中你不需要担心内存分配,而且我正在做一个教程,但是每次我提到realease或autorelease的alloc时都会出错,比如ARC禁止dealloc的显式消息或像那.从现在起我应该忽略对alloc dealloc和release的所有引用吗?或者最好关闭那个ARC的东西?因为我是新手,所以提前告知你的建议
嗨,我一直在努力学习如何添加一些辅助功能工具,但它似乎既不适用于三星galaxy s2也不适用于模拟器.我创建了一个简单的活动,这是一个布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:contentDescription="Title"
android:focusable="true"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:contentDescription="Button to click"
android:focusable="true"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:contentDescription="Small image"
android:focusable="true"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的应用程序设置为最低级别1.6和目标4.0我已添加了android suppport库.不幸的是,当我尝试"触摸"或选择这些项目时,我听不到描述.当然我已经激活了可访问性和TalkBack应用程序,但我这里唯一的事情是"屏幕关闭,音量x%"....还有什么我必须要做的吗?谢谢
我正在尝试创建一个九补丁drawable.我创建了一个带有白色边框的图像,然后在Draw9patch软件中打开它,如下所示:
我不明白我应该做什么.我在它周围画了一些黑色边框,当我在我的应用程序中尝试使用它时,它会给我带来错误.我试图在它周围画一个红色边框,它也给出了相同的错误,九个补丁无效.
有时,九个贴片的区域显示为粉红色,有时显示为绿色.我不明白它意味着什么,任何地方都没有解释.
android ×5
java ×2
animation ×1
c ×1
components ×1
excel ×1
file ×1
html ×1
ioexception ×1
iphone ×1
landscape ×1
nine-patch ×1
pointers ×1
regex ×1
runtime.exec ×1
tags ×1
void ×1