我试图添加,删除和引用我在我的主java文件中创建的数组中的项目,但我无法找出正确的语法.在actionscript中,他们有push()和pop()来添加和删除数组中的项目,在android中是否有相同的东西?
我试图发起一个打开Android市场链接的意图.
android manifest部分看起来像这样:
<activity android:name="com.surreall.sixdice.Start" android:label="Six Dice" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
启动意图如下:
public void onClick(View v) {
String PublisherID = "pub:surreallgames";
Uri marketUri = Uri.parse("market://search?q="+PublisherID);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
}
Run Code Online (Sandbox Code Playgroud)
logcat输出:
06-17 17:38:47.393: E/AndroidRuntime(476): FATAL EXCEPTION: main
06-17 17:38:47.393: E/AndroidRuntime(476): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://search?q=pub:surreallgames }
06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-17 …Run Code Online (Sandbox Code Playgroud) 我有5个方形的ImageButtons,我想在屏幕的底部并排排列.我有每一组(不同的id):
<ImageButton
android:id="@+id/box1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_weight="1"
android:layout_margin="1dp"
/>
Run Code Online (Sandbox Code Playgroud)
我在主java中分配了这样的背景:
int[] imageIds = new int[] {R.id.box1,R.id.box2,R.id.box3,R.id.box4,R.id.box5};
for(int i = 0; i<5; i++){
imageButtons[i] = (ImageButton) findViewById(imageIds[i]);
imageButtons[i].setBackgroundResource(R.drawable.blank);
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是缩放宽度以便在屏幕底部整齐地并排放置(现在可以正常使用),但是高度也会自动缩放以匹配宽度.这可能吗?我不想使用setImageSource,因为它在图像按钮周围放置了一个边框.
我有一个像"asdfHRbySFss"的字符串,我想一次查看一个字符,看看哪些字母大写.我怎么能用Python做到这一点?
我试图找到2到100个小数位的平方根,但它默认只显示为10,我怎么能改变这个?
假设我有一个名为simpleFunction()的函数; 我在我的程序中多次调用.我不想做一个ctrl + f来找到它,是否有更快的方式直接跳转到该功能?
我曾经能够通过点击"图形布局"看到我的布局在eclipse中的样子预览,然后我可以点击另一个名为"main.xml"的标签,看看实际的xml代码.现在我有两个名为"Design"和"Source"的标签.我怎样才能再次回到旧视图?
我在strings.xml文件中有一些项目,我想以编程方式进行更改,最初我是通过setText();调用来完成的,但现在我正在尝试将我的应用程序翻译成另一种语言,这意味着一切都需要在我的字符串中设置. xml文件.是否可以将我的应用程序的所有文本放入strings.xml并通过引用字符串名称以编程方式更改内容,而不是使用setText()函数调用?例如,我如何引用"GrandTotal"?
<string name="GrandTotal">Grand Total:</string>
<string name="choose_prompt">Choose a Mode</string>
Run Code Online (Sandbox Code Playgroud) 我有一个名为Upval16的整数值,我希望存储在我的SharedPreferences中而不为每个创建单独的值,但SharedPrefernces不允许使用Array,最简单的方法是什么?声明看起来像这样:
Integer[] UpVal = new Integer[16];
Run Code Online (Sandbox Code Playgroud) 我有一个相当简单的滚动视图,当我向上滚动时,它不会一直滚动到屏幕顶部.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.surreall.matchit"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:id="@+id/main_layout2"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="1dp"
android:layout_gravity="center"
android:id="@+id/board"
android:layout_weight="6"
android:baselineAligned="false"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
>
<com.surreall.logo.SquareButton
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1" >
<ImageView
android:id="@+id/card1"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="4dp"
/> </com.surreall.logo.SquareButton>
<com.surreall.logo.SquareButton
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1" >
<ImageView
android:id="@+id/card2"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="4dp"
/> </com.surreall.logo.SquareButton>
<com.surreall.logo.SquareButton
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1" >
<ImageView
android:id="@+id/card3"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1" …Run Code Online (Sandbox Code Playgroud) android ×8
eclipse ×2
python ×2
arrays ×1
aspect-ratio ×1
imagebutton ×1
java ×1
layout ×1
math ×1
scrollview ×1
string ×1
xml ×1