コード変更
状態:試行錯誤中
閲覧数:1,544
投稿日:2013-07-25
更新日:2013-07-29
・「初期画面」から「項目入力画面」への遷移がどうしてもうまくいかない
・しょうがないので、以前のメモを参考に、良く分からないままコード変更
・とりあえず遷移するようにはなったが、左から右へスライドしながら遷移するのは何故なんだァああああ?
・しょうがないので、以前のメモを参考に、良く分からないままコード変更
・とりあえず遷移するようにはなったが、左から右へスライドしながら遷移するのは何故なんだァああああ?
現状コード
画面遷移
一番右上にある「+システムアイコン」クリックすると「項目入力画面」へ画面遷移
・インテントのインスタンス生成
・「元画面アクティビティのインスタンス」と「次画面アクティビティのクラス」を明示的に指定
▼/MainActivity.java
// 画面遷移ボタン(+システムアイコン)を押下したとき
addButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Item.class);// インテントのインスタンス生成。 「元画面アクティビティのインスタンス」と「次画面アクティビティのクラス」を明示的に指定
startActivity(intent);
}
});
・Androidマニフェストに、インテント先のクラスを書く
▼/AndroidManifest.xml
<activity android:name="Item"></activity>
文字色変更
2種類
1.XMLファイルにより設定
2.Javaファイルにより設定
1.XMLファイルにより設定
1-1.★★.xmlに直書
1-2.colors.xmlで指定
1-1.★★.xmlに直書
android:textColor
▼/res/layout/item.xml
「android:background」とは異なり、LinearLayoutタブに直接記述できない
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
複数箇所記述した場合、後から色変更するのは大変
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/item_text1"
android:textColor="#ffff00"
android:gravity="center"
android:padding="8.5dip"
/>
<!--上の直線-->
<LinearLayout
android:id="@+id/Linear01"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
</LinearLayout>
<!-- ここまで上の直線 -->
<!--項目-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="12dip"
>
<TextView
android:layout_width="120px"
android:layout_height="wrap_content"
android:text="@string/item_text2"
android:textColor="#ffff00"
/>
1-2.colors.xmlで指定
▼/res/layout/item.xml
<TextView
android:layout_width="120px"
android:layout_height="wrap_content"
android:text="@string/item_text2"
android:textColor="@color/yellow"
/>
<EditText
android:id="@+id/item_edit1"
android:layout_width="200px"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/item_button1"
android:layout_width="80px"
android:layout_height="wrap_content"
android:background ="@android:drawable/ic_menu_search"
android:layout_marginLeft="20.0px"
/>
</LinearLayout>
<!--項目終わり-->
<!--内訳-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="12dip"
>
<TextView
android:layout_width="120px"
android:layout_height="wrap_content"
android:text="@string/item_text3"
android:textColor="@color/yellow"
/>
▼/res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="yellow">#FFFF00</color>
</resources>