PCDVD數位科技討論區

PCDVD數位科技討論區 (https://www.pcdvd.com.tw/index.php)
-   七嘴八舌異言堂 (https://www.pcdvd.com.tw/forumdisplay.php?f=12)
-   -   [?]Android App的View寫法 與 待遇 (https://www.pcdvd.com.tw/showthread.php?t=1050576)

公不 2014-06-01 12:35 AM

[?]Android App的View寫法 與 待遇
 
想要請問一下

在Android中

AlertDialog是透過R.java取得xml拉好的layout

然後經由LayoutInflater轉成View呈現

代碼:
LayoutInflater inflater = (LayoutInflater)Main.this.getSystemService(LAYOUT_INFLATER_SERVICE);

View alertView = inflater.inflate(R.layout.mylayout, null);



現在想說

將這個xml的layout改由java直接new的方式

整個by code方式寫

請問這樣之下

該如何轉到View

因為如果還是用LayoutInflater來呼叫

會出現fc有

android.content.res.Resources$NotFoundException: Resource ID ‪#‎0xa錯誤訊息
-----------------------------------------------------

看來台灣目前還是對軟體非常的看扁?

台北/新竹 起薪33K算是高薪 ?!!!

由硬體轉職軟體

拿40K就算是拿高資歷薪資 ?!!!


謝謝

darkangel 2014-06-01 01:37 AM

1. 沒碰過相同的問題。
2. 因為你的硬體資歷對軟體幾乎是完全無幫助,40K 是不錯的起薪了。

公不 2014-06-01 01:57 AM

本來用Code呈現Layout是打算這樣做

代碼:
mylayou= new RelativeLayout(Main.this);
mylayou.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
mylayou.setX(0.0f);
mylayou.setY(0.0f);
mylayou.setId(10);;
mylayou.getLayoutParams().width=global_val.total_width;
mylayou.getLayoutParams().height=global_val.total_height;

LayoutInflater inflater = (LayoutInflater)Main.this.getSystemService(LAYOUT_INFLATER_SERVICE);

View alertView = inflater.inflate(10, null);


結果不行

戰長 2014-06-01 07:07 AM

引用:
作者公不
本來用Code呈現Layout是打算這樣做

mylayou= new RelativeLayout(Main.this);
mylayou.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
mylayou.setX(0.0f);
mylayou.setY(0.0f);
mylayou.setId(10);;
mylayou.getLayoutParams().width=global_val.total_width;
mylayou.getLayoutParams().height=global_val.total_height;

LayoutInflater inflater = (LayoutInflater)Main.this.getSystemService(LAYOUT_INFLATER_SERVICE);

View alertView = inflater.inflate(10, null);


結果不行


既然你的View都要從java裡面造了
那不需要再從LayoutInflater拉
造出來直接塞到AlertDialog裡就好

類似這樣


代碼:
mylayou = new RelativeLayout(this);

TextView textView = new TextView(this);
textView.setText(R.string.app_name);
mylayou.addView(textView);

new AlertDialog.Builder(this).setView(mylayou).create().show();


不過建議你既然要造自己的dialog
其實可以直接寫一隻class繼承dialog下來客製化
以後使用上也會比較方便


另外硬體轉職軟體
等於是從lv1開始練起
白紙一張可能比大學生還差
這樣的情況下能拿到40k以上
其實已經算非常高薪了


所有的時間均為GMT +8。 現在的時間是09:34 PM.

vBulletin Version 3.0.1
powered_by_vbulletin 2025。