例如,我有一个PHP数组,例如这个
<?php $s= array('a','b','c','d','e','f') ; ?>
Run Code Online (Sandbox Code Playgroud)
我需要在JavaScript中循环它,任何想法我该怎么做?
for ( i=0 ; i < <?php echo sizeof($s) ?> ; i++) {
document.write('<?php echo $s [somehow need to get the 'i' value into here] ?>');
}
Run Code Online (Sandbox Code Playgroud)
有什么建议?谢谢!
无法弄清楚那一个 - 如何在HTTP GET请求中添加cookie?
List<Cookie> cookies = httpcPostlient.getCookieStore().getCookies();
Log.e("cookie_0", cookies.get(0).toString());
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
// request <- how do I set cookies.get(0) into here?
request.setURI(new URI(myUrl));
HttpResponse httpGetResponse = client.execute(request);
}
Run Code Online (Sandbox Code Playgroud) 长话短说,eclipse将ADT和SDK更新到v20,我不喜欢并想回到18.
所以我卸载了ADT和SKD并从中卸载了v18
http://dl.google.com/android/installer_r18-windows.exe
和http://dl.google.com/android/ADT-18.0.0.zip
安装了它们,但现在Eclipse似乎无法找到一些sdk平台并抛出"无法解决目标'android-8'"错误......任何想法可能出错?

我需要安装Sony Tablet S作为ADB设备,以便我可以调试它.
我按照这里的说明完成了 - http://esupport.sony.com/US/perl/support-info.pl?info_id=878
但它仍然没有显示为ADB设备.另一方面,在设备管理器中,它在便携设备/索尼Tablet S中显示为MTP设备.如果我将其卸载然后重新插入,它将自动安装为MTP设备.
任何想法,我如何将其与MTP设备关联并将其与ADB关联?
谢谢!
ps如果我使用更新驱动程序...有磁盘并指向android_winusb.inf,它会说"该文件夹不包含兼容的软件驱动程序......"
假设我在包含某处的资产中有一个.svg文件
<polygon id="collide" fill="none" points="45,14 0,79 3,87 18,92 87,90 98,84 96,66 59,14"/>
Run Code Online (Sandbox Code Playgroud)
您认为找到此多边形并将其点解析为Points []数组的最佳方法是什么?
谢谢!
我正在尝试创建一个可以将JBox2d世界的对象绘制到画布上的类.
在更新时我打电话给
render.draw(canvas,world);
Run Code Online (Sandbox Code Playgroud)
它将世界和画布传递给绘图类,它将循环遍历世界的对象并将它们绘制到画布中.
public void draw(Canvas canvas, World world)
{
canvas.drawColor(0xFF6699FF);
for ( Body b = world.getBodyList(); b!=null; b.getNext() )
{
Log.e("xy", String.valueOf( b.getPosition().x )+" "+String.valueOf( b.getPosition().y ) );
}
}
Run Code Online (Sandbox Code Playgroud)
然而它似乎进入一个无限循环,后退按钮不起作用,然后它说"没有响应"并提供强制关闭.
在这种情况下,任何想法是什么是在身体中循环的正确方法?
谢谢!
final EditText et1 = (EditText)findViewById(R.id.et1);
et1.setOnFocusChangeListener(new OnFocusChangeListener(){
@Override
public void onFocusChange(View v, boolean hasFocus) {
if ( hasFocus )
{
et1.setTextColor(0xFF000000);
if ( et1.getText().equals("Email") ) { et1.setText(""); }
}
else
{
et1.setTextColor(0xFF7F7F7F);
if ( et1.getText().equals("") ) { et1.setText("Email"); }
}
}
});
Run Code Online (Sandbox Code Playgroud)
et1默认包含"Email".当用户点击它时,我希望它清除.在OnFocusChangeListener细如颜色变化的作品,但文字不改变,即
if ( et1.getText().equals("Email") )
Run Code Online (Sandbox Code Playgroud)
不开火.equals("")我清除了et之后也没有.
我究竟做错了什么?
假设我有一个字符"a",我需要将其与符号(̌)组合,我以十六进制值"030c"的形式.
您认为将它们组合起来的最佳方式是什么?
PS谢谢,"\ u030c"确实给了在logcat,但在Android本身,它只是显示一个空白的方块.有没有办法解决它而无需用户安装其他字体?
编辑:
我有一个应用程序写入SharedPreferences像这样:
Context otherAppsContext = null;
try {
otherAppsContext = createPackageContext("AfroKeyboard.com.rob", Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
}
SharedPreferences sharedPreferences = otherAppsContext.getSharedPreferences("PREFS_PRIVATE", Context.MODE_WORLD_READABLE);
Editor prefsPrivateEditor = sharedPreferences.edit();
prefsPrivateEditor.putString("layout02", jString);
prefsPrivateEditor.putString("layout02name", "Russian Layout");
prefsPrivateEditor.commit();
Run Code Online (Sandbox Code Playgroud)
和另一个必须从他们读取的应用程序
Context otherAppsContext = null;
try {
otherAppsContext = createPackageContext("AfroKeyboard.com.rob", Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
}
SharedPreferences sharedPreferences = otherAppsContext.getSharedPreferences("PREFS_PRIVATE", Context.MODE_WORLD_READABLE);
Log.e( "name2" , "name2: "+sharedPreferences.getString("layout02name", "") );
Run Code Online (Sandbox Code Playgroud)
但它返回空.
您认为可能是什么问题?
谢谢!