RatingBarの実装
アクティビティ
public class MainActivity extends AppCompatActivity implements RatingBar.OnRatingBarChangeListener { RatingBar mRatingBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRatingBar = (RatingBar) findViewById(R.id.rating); mRatingBar.setOnRatingBarChangeListener(this); //最大星数 mRatingBar.setNumStars(6); // ステップ mRatingBar.setStepSize(1); // レーティングをセットする mRatingBar.setRating(3); } @Override public void onRatingChanged ( RatingBar ratingBar, float rating, boolean fromUser ) { Toast.makeText(getApplicationContext(), String.valueOf(ratingBar.getRating()), Toast.LENGTH_SHORT).show(); } }
xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="jp.co.araiyusuke.ratingbar.MainActivity"> <RatingBar android:id="@+id/rating" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout>
Herokuでアクセス制御を実装する(PHP)
IP取得
HerokuのPHPからIPを取得するには、$_SERVER["REMOTE_ADDR"]ではなく、$_SERVER['HTTP_X_FORWARDED_FOR']を利用する。Herokuのシステムはクライアントとサーバーの間に、ロードバランサーという負荷分散システムの仕組みが導入されているらしく、$_SERVER["REMOTE_ADDR"]には、ロードバランサーのIPが代入されている。
<?php $ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR'] ; echo $ipAddress . "<br>"; echo gethostbyaddr($ipAddress); ?>
.htaccess
SetEnvIf X-Forwarded-For 124.***.***.*** denyIp1 SetEnvIf X-Forwarded-For 124.***.***.*** denyIp2 order allow,deny allow from all deny from env=denyIp1 deny from env=denyIp2
確定申告について
医療費控除
所得金額から差し引くことが出来る。
自分が実際に支払った医療費が10万を超えた場合は
医療費 - 10万 = 医療費控除
この条件以外にも、所得が200万までの人であれば
自分が支払った医療費 - 所得の合計額の5%
保険に加入しており保険金で支払った部分を補填といい、これは実際に支払った医療費の対象にはならない。
生命保険料控除
契約した年によって新旧がある。
新旧どっちになるのかわからない場合は、保険会社から届いた控除証明書を確認すれば記載があります。
平成24(2012)年1月1日以降に契約すれば新、平成23(2011)年12月31日以前は旧