我对作为服务器响应的JSONObject进行了一些修复.
jsonObj = new JSONObject(resultString);
JSONObject sync_reponse = jsonObj.getJSONObject("syncresponse");
String synckey_string = sync_reponse.getString("synckey");
JSONArray createdtrs_array = sync_reponse.getJSONArray("createdtrs");
JSONArray modtrs_array = sync_reponse.getJSONArray("modtrs");
JSONArray deletedtrs_array = sync_reponse.getJSONArray("deletedtrs");
String deleted_string = deletedtrs_array.toString();
{"syncresponse":{"synckey":"2011-09-30 14:52:00","createdtrs":[],"modtrs":[],"deletedtrs":[{"companyid":"UTB17","username":"DA","date":"2011-09-26","reportid":"31341"}]
Run Code Online (Sandbox Code Playgroud)
正如你在我得到的响应中看到的那样,我正在解析JSONObject并创建syncresponse,synckey作为JSON对象 createdtrs,modtrs,deletedtrs作为JSONArray.我想从deletedtrs访问JSONObject,以便我可以拆分它们并使用这些值.即我想提取companyid,用户名,日期等.
我怎么能这样做?
感谢您的输入.
我想在按下一个按钮后将EditText重置为空的"空格"或"提示",该按钮将完成一个带有EditText字段输入的活动.
我的Android冒险因此召唤.
干杯.谢谢 !!
//************-------------------SEND SMS----------------*********//
btnSendSMS = (Button)findViewById(R.id.sms);
btnSendSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
sendSMS(dispEd.getText().toString(),msgEd.getText().toString());
}
private void sendSMS(String phoneNumber, String msg) {
// TODO Auto-generated method stub
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, msg, null, null);
}
});
}
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/edit"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/msg"/>
Run Code Online (Sandbox Code Playgroud) 我想导入一个字体.在线查找了一些教程并使用了说明.到目前为止,我已将字体导入assets文件夹.这是我用来声明我的字体类型的代码.
Typeface localTypeface1 = Typeface.createFromAsset(getAssets(), "arial.ttf");
Run Code Online (Sandbox Code Playgroud)
当我调用它时,我一直得到空指针异常.
TextView txtTab = new TextView(this);
txtTab.setTypeface(localTypeface1);
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢 ?这是logcat中的确切错误.
11-17 13:10:41.024: E/AndroidRuntime(2262): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{se.copernicus.activity/se.copernicus.activity.Secondactivity}: java.lang.NullPointerException
11-17 13:10:41.024: E/AndroidRuntime(2262): at android.content.ContextWrapper.getAssets(ContextWrapper.java:74)
Run Code Online (Sandbox Code Playgroud)
这是第74行
Typeface localTypeface1 = Typeface.createFromAsset(getAssets(), "arial.ttf");
Run Code Online (Sandbox Code Playgroud)
我在使用BroadCast接收器检查Wi-Fi状态时遇到了一些麻烦.能否请你帮忙?
这是我的清单文件.
<uses-permission android:name="android.permission.READ_PHONE_STATE"> </uses-permission>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"> </uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"> </uses-permission>
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".MainActivity">
<intent-filter android:name="android.net.wifi.WIFI_STATE_CHANGED"/>
</receiver>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这是MainActivity.java
public class MainActivity extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, -1);
String msg = null;
switch (state) {
case WifiManager.WIFI_STATE_DISABLED:
msg = "it is disabled";
break;
case WifiManager.WIFI_STATE_ENABLED:
msg = "it is enabled";
break;
case …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的活动实现Tab View.我收到一个错误.
java.lang.IllegalArgumentException:您必须指定一种创建选项卡指示符的方法
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, MonthActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("Month")
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the …
Run Code Online (Sandbox Code Playgroud) 我想为我在应用程序中构建的选项卡实现圆角。到目前为止,我能够想出这个
我希望我的圆角看起来如此。(我已将其编码为仅显示左右角,但当状态更改时,它看起来像上图)
下面是我到目前为止编写的代码。如何通过代码实现适当的圆角?
选定的 TAB.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
android:topRightRadius="10dp"
android:bottomLeftRadius="10dp"/>
<gradient
android:startColor="#000"
android:endColor="#000"
android:gradientRadius="400"
android:angle="-270"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
未选择的 TAB.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:angle="90"
android:startColor="#880f0f10"
android:centerColor="#8858585a"
android:endColor="#88a9a9a9"/>
<corners
android:topLeftRadius="10dp"
android:bottomRightRadius="10dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
感谢您的答复 !!:)
我想将信息从HTML表单传递到PHP页面.我的问题是表单中的数据没有提交.我究竟做错了什么 ?
HTML表格
<div id="go">
<form method="get" action="client_authorized.php">
<fieldset>
<input type="text" name="query" class="input-text" />
<input type="submit" value="Secure Client Access" class="input-submit" />
</fieldset>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
client_authorized.php
<?php
print $_GET['query'];
?>
Run Code Online (Sandbox Code Playgroud) 我的 xml 文件有问题。好吧,它起初工作正常,但后来我想给它一个滚动视图,所以我将滚动视图添加到 main.xml 中。保存文件后。该应用程序曾经在未启动的情况下崩溃。看到这一点,我删除了 main.xml 文件上的滚动视图,并面临一个新问题,其中所有按钮都相互重叠。
另外,如果您能告诉我如何正确提供滚动视图标签,那将很有帮助。干杯。谢谢 !
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Creating and Using Databases without Content Provider"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/edit"
android:padding="6dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/msg"
android:padding="6dip"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text = "Add a new book"
android:id="@+id/addTitle"
android:padding="6dip"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/upTitle"
android:text="Update a book"
android:padding="6dip"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/rtrTitles"
android:text="Retrieve all books"
android:padding="6dip"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/rtrTitle"
android:text="Retrieve Specific book"
android:padding="6dip"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/delTitle"
android:text="Delete a book" …
Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中的选项卡旁边放置一个按钮.我已经给出了下面的代码,我将如何构建我的Tabs.
这是XML
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="330dp"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="0.5dip"
android:background="#000" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#696969" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#000" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
我的活动代码:
public class Secondactivity extends TabActivity {
protected void onCreate(Bundle savedInstanceState) {
setupTabHost();
mTabHost.getTabWidget().setDividerDrawable(se.copernicus.activity.R.drawable.tab_divider);
setupTab(new TextView(this), "Month");
setupTab(new TextView(this), "Week");
setupTab(new TextView(this), "Day");
setupTab(new TextView(this), "Today");
private void setupTab(final View view, final String tag) {
View tabview = …
Run Code Online (Sandbox Code Playgroud) 我使用 Bitnami 来设置和运行 wordpress。当我遇到一些问题时,我决定将软件更改为XAMPP。这就是问题出现的地方。当我在网络浏览器中输入 localhost 时,它会显示 Bitnami 欢迎页面。XAMPP的localhost不应该来吗?我该如何解决这个问题。下面是我输入 localhost 时浏览器的屏幕截图。
我写了一小段代码来测试两个参数并将用户转发到一个链接.
error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "On");
$secure_box=$_GET['query'];
$fh = fopen('db.csv', 'r');
$now = date("d.m.Y");
$data=fgetcsv($fh);
$first_name=$data[0];
$date=$data[1];
$url=$data[2];
{
if($secure_box == $first_name AND $date>=$now)
{
header("Location: $url");
exit();
}
else
{
header("Location: http://localhost/x/delivery_method.html");
}
exit;
?>
Run Code Online (Sandbox Code Playgroud)
我的问题是没有读取整个CSV文件.我能做什么 ?
正如我的问题所说,我想将我的arraylist项插入到hashmap中.
这是我的HashMap.
HashMap<String, Integer> unSorted = new HashMap<String, Integer>();
Run Code Online (Sandbox Code Playgroud)
这是我的ArrayList.
arrayList.add("1");
arrayList.add("2");
Run Code Online (Sandbox Code Playgroud)
添加到Hashmap中.
unSorted.put(arrayList,50);
Run Code Online (Sandbox Code Playgroud)
我很确定我不能添加像这样的arraylist.我忘了我必须迭代arrayList并逐个插入值.
我怎么会出错?
感谢您的时间 !