我试图使用xml代码显示日期选择器.但它没有显示任何东西.我可以只通过java代码显示DatePicker吗?
public class datePickerExample extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.date_picker_example);
}
}
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lay_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Date : " >
</TextView>
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:endYear="2100"
android:startYear="1900" >
</DatePicker>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢...
服务器有两个参数:String和JSON.提示,正确我JSON在POST请求中传输和字符串?
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("my_url");
List parameters = new ArrayList(2);
JSONObject jsonObject = new JSONObject();
jsonObject.put("par_1", "1");
jsonObject.put("par_2", "2");
jsonObject.put("par_3", "3");
parameters.add(new BasicNameValuePair("action", "par_action"));
parameters.add(new BasicNameValuePair("data", jsonObject.toString()));
httpPost.setEntity(new UrlEncodedFormEntity(parameters));
HttpResponse httpResponse = httpClient.execute(httpPost);
Log.v("Server Application", EntityUtils.toString(httpResponse.getEntity())+" "+jsonObject.toString());
} catch (UnsupportedEncodingException e) {
Log.e("Server Application", "Error: " + e);
} catch (ClientProtocolException e) {
Log.e("Server Application", "Error: " + e);
} catch (IOException e) {
Log.e("Server Application", …Run Code Online (Sandbox Code Playgroud) 我的xml for android有问题.我有这个布局在Listview的每一行中使用它(工作正常).
我想放两行(头部和正文)的文本,并对齐第一行的右边我必须放两个ImageView.(首先还有一个隐藏的textView)
像这样的东西:

我的问题是当我尝试放两个imageViews(只有一个它显示正常,但有两个没有显示任何东西).
这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/TvIdGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/TvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textSize="30sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/ImgNewConvGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="@drawable/new_messages" />
<ImageView
android:id="@+id/ImgNewGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="@drawable/new_group" />
</LinearLayout>
<TextView
android:id="@+id/TvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:textStyle="normal" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
抱歉我的英文,并提前感谢你!
这是我的Javascript formvalidator函数:
function companyName() {
var companyName = document.forms["SRinfo"]["companyName"].value;
if (companyName == ""){
return false;
} else {
return true;
}
}
function companyAdd() {
var companyAdd1 = document.forms["SRinfo"]["companyAdd1"].value;
if (companyAdd1 == ""){
return false;
} else {
return true;
}
}
function companyCity() {
var companyCity = document.forms["SRinfo"]["companyCity"].value;
if (companyCity == ""){
return false;
} else {
return true;
}
}
function companyZip() {
var companyZip = document.forms["SRinfo"]["companyZip"].value;
if (companyZip == ""){
return false;
} else {
return true; …Run Code Online (Sandbox Code Playgroud) 我试图设置我的ImageView调整大小,但它不能通过位图或其他方法我将放置我的代码,所以如果任何人都可以帮助我如何调整大小ImageView以适应表行thnx.
public class Test extends Activity
{
private TableLayout Table1;
protected void onCreate(Bundle savedInstanceState)
{
int[] ImageArray={R.raw.hospital_image,R.raw.hotel_image};
super.onCreate(savedInstanceState);
setContentView(R.layout.favorites);
Table1 = (TableLayout) findViewById(R.id.Table);
TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT, 1.0f);
for(int i=0;i<ImageArray.length;i++)
{
TableRow TR = new TableRow(this);
TR.setLayoutParams(tableRowParams);
ImageView img=new ImageView(this);
//What should i do here to resize it ???
Drawable d = getResources().getDrawable(ImageArray[i]);
img.setImageDrawable(d);
TR.addView(img, new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT, 1.0f));
Table1.addView(TR);
}
}
Run Code Online (Sandbox Code Playgroud)
我的XMl只包含这些:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView …Run Code Online (Sandbox Code Playgroud) <?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" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/11" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
它只是,android项目正常设置,我把它放在每个文件夹中的图像11与默认图标大小相同,我不能让它进入模拟器,因为这个错误,它甚至不会运行, 你能帮我吗?
我是Android开发的新手.我想知道如何使用android:layout_gravity属性,我可以使用此选项将视图定位在屏幕宽度的中心.
我尝试了以下但是它在顶部对齐
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Table Layout" />
<TableRow>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:hint="username" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:hint="password"
android:inputType="textPassword" />
</TableRow>
<TableRow>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="SAVE" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="CANCLE" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
我的输出是:

我在获取一维方面遇到问题 JSON请指导我问题在我JSON或我的代码中?
JSON:
{
"data": {
"id": "S000010",
"name": "ZS Solutions",
"email": "zswebs@gmail.com",
"phone": "051-1234567",
"address": "p.o.box 123",
"about": "im the company\r\nHAhahhaa"
}
}
Run Code Online (Sandbox Code Playgroud)
Android活动JSON检索代码:
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
// TODO Auto-generated method stub
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("abc.php?Id="+id+"");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse hresponse = httpclient.execute(httppost);
HttpEntity entity = hresponse.getEntity();
is = entity.getContent();
String result=co(is);
JSONObject json=new JSONObject(result);
JSONArray a= json.getJSONArray(data);
for (int i = 0; i <= …Run Code Online (Sandbox Code Playgroud) 当涉及到加载浏览器,浏览器支持,我可能没有想到的任何东西等等.在Javascript中声明的绝大部分或全部样式是否会伤害最终用户包括CSS样式表?
我把一个快速的例子拼凑在一起,如下所示,以及这个小提琴
HTML:
<body onload="init();">
<div class="container">
<div class="row">
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
</div>
<div class="row">
<div class="col"></div>
<div class="col"></div>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
var init = function() {
// Using window object to set global variables
// since global variables are attached to the window object anyway
window.container = document.getElementsByClassName("container");
window.row = document.getElementsByClassName("row");
// Initialize variables
window.rows = [];
window.cols = [];
// Get chidren counts but also setup for future use
window.setCounts();
// Now lets …Run Code Online (Sandbox Code Playgroud) android ×6
html ×2
javascript ×2
json ×2
alignment ×1
css ×1
datepicker ×1
http-post ×1
imageview ×1
listview ×1
performance ×1
php ×1
post ×1
validation ×1
xml ×1