當前位置:首頁 » 安卓系統 » android表單

android表單

發布時間: 2022-02-14 23:31:30

㈠ android中如何請求表單 獲得返回數據

表單的驗證一直是網頁設計者頭痛的問題,表單驗證類 Validator就是為解決這個問題而寫的,旨在使設計者從紛繁復雜的表單驗證中解放出來,把精力集中於網頁的設計和功能上的改進上。

㈡ android webview 有獲取到表單提交數據嗎

是可以獲取到的,可以通過java的對象,將數據傳遞到java裡面,回調取得值。

㈢ android能根據json動態生成一個form表單嗎

你是做web開發的吧?
問題要發到 電腦/網路—>軟體開發—>移動開發下比較准確。

android上是沒有form表單的概念的,通常用listView列表來顯示。

前幾天給別人寫了一個這樣的demo,如果有需要,可以留下郵箱發給你

㈣ android中怎麼創建一個表格

效果圖:


5、 單擊該項目,執行。便得到以上效果!

㈤ android html.formhtml 支持哪些屬性

屬性:位於 form 表單外的輸入欄位(:
<form action="demo-form.php" id="form1">
First name: <input type="text" name="fname"><br>
<input type="submit" value="提交">
</form>
最終代碼如下(Text是字體顏色):
webView.getSettings().setDefaultTextEncodingName("UTF -8");
webView.loadData("<html><bodytext=\"#494949\">" + message.getContent().replace("\\r", "") + "</body></html>",
"text/html; charset=UTF-8", null);

㈥ android webview 怎樣攔截form表單

如果懶得讀文檔,倒是可以看這篇
https://github.com/cnzx219/my-note/blob/master/2015/android-webview-intercept-request.md
public WebResourceResponse shouldInterceptRequest(WebView view, final WebResourceRequest request)

request 裡面就可以獲取到 payload

㈦ 怎樣設置 android form-data

form data是表格中的數據。Access 2010中的表,即為form data。
表是用來存儲數據的基本對象,它是資料庫的資源中心,是資料庫最基本的組件。資料庫中的每個表都包含有關某個主題的信息。在導航窗格中,在表對象上雙擊就可以打開表。
表是由列和行組成的二維結構的表格。一列中顯示某種類型的信息,在這列的最上方是列標題,描述這列的信息類型,也叫做欄位名。在標題下面列出的這個類型中具體內容的數據為欄位值。在同一行中的所有欄位值構成一條記錄。記錄由具體的欄位值構成,一個記錄就是一條獨立的信息。

安卓手機怎麼做表格

以安卓手機系統為例,在手機上做表格方法如下:

1、在手機應用商店搜索WPS Office,找到應用程序後,下載安裝。

㈨ android客戶端如何提交表單數據給web伺服器

1.伺服器端的准備
為了完成該實例,我們需要在伺服器端做以下准備工作:
(1)我們需要在MyEclipse中創建一個Web工程,用來模擬伺服器端的Web服務,這里,我將該工程命名為了「myhttp」。
(2)修改該工程的「index.jsp」文件,添加兩個輸入框和一個提交按鈕,作為該Web工程的顯示頁面。運行Tomcat,在瀏覽器中訪問該Web工程,可以看到如圖1所示的界面。

Web工程的顯示頁面
(3)在該Web工程中,創建一個繼承自HttpServlet的LoginAction類,並實現其中的doPost()方法,用來響應圖1所示頁面的用戶操作。具體實現如下:

由上述代碼可以看出,當我們在圖1所示的頁面輸入用戶名「admin」,密碼「123」時,點擊提交按鈕,會得到「Login succeeded!」的提示信息,如圖2所示。若用戶名、密碼錯誤,則會得到「Login failed!」的提示信息。
2.客戶端實現
在Android客戶端,我們需要完成的工作是:以POST方式發送用戶名密碼到上述伺服器,並獲得伺服器的驗證信息。
我們分以下幾個步驟來完成。
2.1 UI界面
在Android工程中,我們需要完成一個簡單的UI界面,用來完成用戶名密碼的輸入、發送POST請求、顯示伺服器的驗證結果,完成後的界面如圖3所示。
在MainActivity中,我們需要獲取兩個EditText控制項的輸入,「提交」按鍵的監聽,以及伺服器驗證結果的TextView內容顯示。具體實現代碼如下:

2.2發送POST請求到伺服器
可以看到上述代碼中,我們調用了HttpUtils類的靜態方法submitPostData()完成了發送POST請求到伺服器,並將該方法的返回值(伺服器的響應結果)顯示在了TextView控制項中。

通過以上的代碼可以看出,在該方法中,其實完成了3件事:
(1)將用戶名密碼封裝成請求體,這是通過調用getRequestData()方法來實現的(後面會講到這個方法的具體實現)。
(2)設置HttpURLConnection對象的各種參數(其實是設置HTTP協議請求體的各項參數),然後通過httpURLConnection.getOutputStream()方法獲得伺服器輸出流outputStream,再使用outputStream.write()方法將請求體內容發送給伺服器。
(3)判斷伺服器的響應碼,通過httpURLConnection.getInputStream()方法獲得伺服器的響應輸入流,然後再調用dealResponseResult()方法處理伺服器的響應結果。
2.3封裝請求體
使用POST請求時,POST的參數不是放在URL字元串里,而是放在HTTP請求數據中,所以我們需要對POST的參數進行封裝。
針對該實例而言,我們發送的URL請求是:http://192.168.1.101:8080/myhttp/servlet/LoginAction,但是我們需要將POST的參數(也就是username和password)封裝到該請求中,形成如下的形式:
2.4處理響應結果
最後,我們再來看一看對伺服器返回結果的處理是怎樣的。因為在本實例中,伺服器的返回結果是字元串「Login succeeded!」或「Login failed!」,所以這里我們需要做的就是將伺服器的返回結果輸入流轉化成字元串。當然了,如果伺服器返回的是圖片,那麼,我們就需要就得到的輸入流轉化成Bitmap圖片了。如下代碼是上面代碼中用到的dealResponseResult()方法的具體實現。
2.5運行效果

㈩ android平板 怎麼設計好看的表單

1.來說下主程序MainActivity.java
public class MainActivity extends Activity {
private TableLayout table;
private Button select;
EmployeeDao = new EmployeeDao(this);
private Button add;
private Button update;
int selectedRow = 0;
int ActivityID=1;
List<Employee> list = new ArrayList<Employee>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
table = (TableLayout) this.findViewById(R.id.table);
table.setBackgroundColor(Color.GREEN);
//table.set
add = (Button) this.findViewById(R.id.add);
update = (Button) this.findViewById(R.id.update);
select = (Button) this.findViewById(R.id.select);
// 點擊查詢按鈕處理事件
// Toast.makeText(this, "已查詢過了!", Toast.LENGTH_SHORT).show();
select.setOnClickListener(new selectListener());
// 點擊添加按鈕事件處理,跳轉到另一個activity
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent();
i.setClass(MainActivity.this, AddAndUpdateActivity.class);
Bundle bundle=new Bundle();
ActivityID=1;
bundle.putInt("ID", ActivityID);
i.putExtras(bundle);
startActivity(i);
}
});
// 更新員工信息
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent();
i.setClass(MainActivity.this, AddAndUpdateActivity.class);
Bundle bundle=new Bundle();
ActivityID=2;
bundle.putInt("ID", ActivityID);
bundle.putInt("emID", selectedRow);
i.putExtras(bundle);
startActivity(i);
}
});
}

// 查詢信息監聽類
private class selectListener implements View.OnClickListener {
@Override
public void onClick(View v) {
list = .getAll();
if (list.size() != 0) {
for (int i = 0; i < list.size(); i++) {
TableRow row = new TableRow(MainActivity.this);
Employee em = list.get(i);// 查找所有員工信息
// 設置行標記
row.setId(em.getId());
row.setPadding(6, 1, 6, 1);
row.setGravity(Gravity.CENTER);
row.setBackgroundColor(Color.WHITE);
TextView view1 = new TextView(MainActivity.this);
view1.setText(Integer.toString(em.getId()));
view1.setGravity(Gravity.CENTER);//文本居中
view1.setTextSize((float) 18);文本大小
view1.setTextColor(Color.RED);
view1.setPadding(10, 2, 10, 2);//邊框左、上、右、下
row.addView(view1);添加一行
TextView view2 = new TextView(MainActivity.this);
view2.setText(em.getName());
view2.setTextSize((float) 18);
view2.setPadding(10, 2, 10, 2);
row.addView(view2);
TextView view3 = new TextView(MainActivity.this);
view3.setText(Integer.toString(em.getAge()));
view3.setTextSize((float) 18);
view3.setGravity(Gravity.CENTER);
view3.setPadding(10, 2, 10, 2);
row.addView(view3);
TextView view4 = new TextView(MainActivity.this);
view4.setText(em.getPosition());
view4.setTextSize((float) 18);
view4.setPadding(10, 2, 10, 2);
row.addView(view4);
TextView view5 = new TextView(MainActivity.this);
view5.setText(em.getDepartment());
view5.setTextSize((float) 18);
view5.setPadding(10, 2, 10, 2);
row.addView(view5);
TextView view6 = new TextView(MainActivity.this);
view6.setText(em.getWorkdate());
view6.setTextSize((float) 18);
view6.setPadding(10, 2, 10, 2);
row.addView(view6);
TextView view7 = new TextView(MainActivity.this);
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = format.parse(em.getWorkdate());
} catch (ParseException e) {
e.printStackTrace();
}
float d= (float)((new Date().getTime()-date.getTime())/(24*60*60*1000)/365);//計算工齡
String dd=Integer.toString((int) d+1);
view7.setText(dd);
view7.setTextSize((float) 18);
view7.setPadding(10, 2, 10, 2);
row.addView(view7);
table.addView(row);
row.setOnClickListener(new View.OnClickListener() {//點擊某行觸發事件
@Override
public void onClick(View v) {
System.out.println("行標記:" + v.getId());
for (int i = 0; i < table.getChildCount(); i++) {
if (table.getChildAt(i).getId() != v.getId())
table.getChildAt(i).setBackgroundColor(Color.WHITE);
// 選中時,高亮顯示即設置背景色
v.setBackgroundColor(Color.YELLOW);
}
selectedRow = v.getId();
AlertDialog.Builder dialog = new AlertDialog.Builder(
MainActivity.this);
dialog.setTitle("請確認:");
dialog.setMessage("是否刪除這條記錄?");
dialog.setPositiveButton("確定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,int which) {
EmployeeDao = new EmployeeDao(MainActivity.this);
.delete(selectedRow);
Toast.makeText(MainActivity.this,
"刪除成功", Toast.LENGTH_SHORT).show();
Intent i = new Intent();
i.setClass(MainActivity.this,MainActivity.class);
startActivity(i);
}
});
dialog.setNegativeButton("取消",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
} });
dialog.show();
}
});
}
}
}
}
}

2.然後是添加和更新的界面,兩個功能使用同一個xml文件布局

<RelativeLayout
android:background="#2691f2"
tools:context=".AddAndUpdateActivity" >

<TextView
android:id="@+id/t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="25sp"
android:text="@string/addinfo"
android:textColor="#bc4b86" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/t"
android:orientation="vertical" >

<TextView
android:layout_width="wrap_content"
android:layout_height="30dp" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name" />

<EditText
android:id="@+id/nm"
android:inputType="text"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/age" />

<EditText
android:id="@+id/ag"
android:inputType="text"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/position" />

<EditText
android:id="@+id/pzs"
android:inputType="text"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dptmt" />

<EditText
android:id="@+id/dptmt"
android:inputType="text"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/date" />

<EditText
android:id="@+id/wkdt"
android:inputType="text"
android:layout_width="150dp"
android:layout_height="wrap_content" />
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="20dp" />

<Button
android:id="@+id/addnew"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:text="@string/add" >
</Button>
</LinearLayout>

</RelativeLayout>

熱點內容
編程一首詩 發布:2025-02-06 06:45:04 瀏覽:528
驚聲尖笑5下載ftp 發布:2025-02-06 06:33:16 瀏覽:528
共享文件夾讓輸入密碼 發布:2025-02-06 06:32:28 瀏覽:970
收銀伺服器響應出錯什麼意思 發布:2025-02-06 06:24:43 瀏覽:607
sql用戶授權 發布:2025-02-06 06:24:42 瀏覽:677
蘋果手機相冊顯示正在上傳 發布:2025-02-06 06:05:43 瀏覽:542
hadoop下載文件夾 發布:2025-02-06 06:05:08 瀏覽:187
鎧最強配置是哪些 發布:2025-02-06 06:04:22 瀏覽:360
編譯器的製作環境 發布:2025-02-06 05:54:34 瀏覽:829
學車網源碼 發布:2025-02-06 05:47:40 瀏覽:386