スクロールビューと子コンテナを使用してXMLレイアウトを変更するまで、Androidアプリケーションは完全に実行されていました。線形レイアウトでは、その下に多くのコントロールがあります。この特定のレイアウトはもう実行されておらず、アプリが機能しなくなります。また、IDEがタグがAndroidリソースの有効な要素ではないと言ったことがあります。しかし、IDEを更新すると、修正されました。しかし、現在、計算を伴うこの特定のレイアウトは機能していません。この問題の解決策は何でしょうか。私は本当にこのアプリをできるだけ早く完成させる必要があります。:| このレイアウトだけが機能していません...
新しいプロジェクトを再度作成し、XMLレイアウトをコピーして貼り付けることを計画していますが、これは私の問題の解決策になる可能性がありますか?それに加えて、このレイアウトが以前は正しく機能していたすべてのバックアップファイルが機能しなくなりました。私はこれで苦労しています。
INTELLIJ LEDA COMMUNITYEDITIONIDEを使用しています。どんな助けでもいただければ幸いです!XMLは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:background="#ffffff">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_width="30dp" android:layout_height="30dp"
android:id="@+id/btn_home_monthly" android:background="@drawable/home" android:textColor="#ffffff"
android:layout_gravity="right"/>
<Button android:layout_width="30dp" android:layout_height="30dp"
android:id="@+id/btn_warning_from_monthlycomputation"
android:background="@drawable/warn" android:layout_gravity="right"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Input your Monthly Net Salary:"
android:id="@+id/textView" android:layout_gravity="center"
android:textColor="@android:color/black" android:textStyle="bold"/>
<EditText
android:layout_width="130dp"
android:layout_height="wrap_content"
android:id="@+id/et_net_monthly" android:layout_gravity="center" android:inputType="numberDecimal|numberSigned">
<requestFocus/>
</EditText>
<Button android:layout_width="150dp" android:layout_height="40dp" android:text="Compute"
android:id="@+id/btn_compute_from_monthly" android:background="@drawable/black_btn" android:textColor="#ffffff"
android:layout_gravity="center"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Tax Due:" android:id="@+id/textView1"
android:layout_gravity="center" android:textColor="@android:color/black" android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt_taxdue" android:textColor="#ff0006" android:layout_gravity="center"
android:textSize="20dp"
android:textStyle="bold"/>
<Button android:layout_width="150dp" android:layout_height="40dp" android:text="Show Breakdown"
android:id="@+id/btn_showbreakdown" android:background="@drawable/black_btn"
android:textColor="#ffffff" android:layout_gravity="center" android:visibility="invisible"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt_1" android:layout_gravity="left|center_vertical" android:visibility="invisible"
android:textColor="@android:color/black"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txt_2"
android:layout_gravity="left|center_vertical" android:visibility="invisible"
android:textColor="@android:color/black"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txt_3"
android:layout_gravity="left|center_vertical" android:visibility="invisible"
android:textColor="@android:color/black"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txt_4"
android:layout_gravity="left|center_vertical" android:visibility="invisible"
android:textColor="@android:color/black"/>
<Button android:layout_width="150dp" android:layout_height="40dp" android:text="Save As Text File"
android:id="@+id/btn_save" android:background="@drawable/black_btn" android:textColor="#ffffff"
android:layout_gravity="center" android:visibility="invisible"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txt_filename"
android:layout_gravity="left|center_vertical" android:visibility="invisible"
android:textColor="@android:color/black"
android:text="Name for File:"/>
<EditText
android:layout_width="130dp"
android:layout_height="wrap_content"
android:id="@+id/et_txtname" android:layout_gravity="center" android:inputType="textFilter"
android:visibility="invisible">
<requestFocus/>
</EditText>
<Button android:layout_width="150dp" android:layout_height="40dp"
android:id="@+id/btn_confirm" android:background="@drawable/save"
android:layout_gravity="center" android:visibility="invisible"/>
</LinearLayout>
</ScrollView>
これはそのクラスです:
public class MonthlyComputation extends MyActivity
{
private String civil_status;
String ns, td, r, e, s, to, wr, n, txtname, stat;
String datetime = DateFormat.getDateTimeInstance().format(new Date());
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.monthlycomputation);
Bundle extras = getIntent().getExtras();
if(extras != null)
{
civil_status = extras.getString("user_status");
}
Button btn_compute = (Button) findViewById(R.id.btn_compute_from_monthly);
Button btn_warning = (Button) findViewById(R.id.btn_warning_from_monthlycomputation);
final Button btn_show = (Button) findViewById(R.id.btn_showbreakdown);
final Button btn_save = (Button) findViewById(R.id.btn_save);
final Button btn_confirm = (Button) findViewById(R.id.btn_confirm);
final EditText et_txtfile = (EditText) findViewById(R.id.et_txtname);
final TextView txt_name = (EditText) findViewById(R.id.txt_filename);
final Button btn_home = (Button) findViewById(R.id.btn_home_monthly);
btn_home.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent i = new Intent(getApplicationContext(), MyActivity.class);
startActivity(i);
}
});
/* SAVING TEXT FILE */
btn_confirm.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
txtname = et_txtfile.getText().toString();
/* Getting the status */
if ("SME".equals(civil_status))
{
stat = "Single / Married with 0 Dependent";
}
else if ("SM1".equals(civil_status))
{
stat = "Single / Married with 1 Dependent";
}
else if ("SM2".equals(civil_status))
{
stat = "Single / Married with 2 Dependents";
}
else if ("SM3".equals(civil_status))
{
stat = "Single / Married with 3 Dependents";
}
else if ("SM4".equals(civil_status))
{
stat = "Single / Married with 4 Dependents";
}
try
{
File f1=new File("/sdcard/download/" + txtname + ".txt");
BufferedWriter out = new BufferedWriter(new FileWriter(f1,true));
out.write("\n\nCreated On: " + datetime + " | Monthly Computation | " + stat + "\n\n"
+ "Net Salary: " + n + "\nTax Due: " + td + "\n\nBreakdown:\n\n"
+ "> Net Salary (" + n + ") - Lower Limit (" + s + ") = " + to +
"\n" + "> " + to + " * Tax Rate (" + r + ") = " + wr + "\n"
+ "> Exemption (" + e + ") + " + wr + " = " + td + "\n"
+ "> Total Tax Due: " + td + "\n");
out.close();
Toast toast = Toast.makeText(getApplicationContext(), "Your file " + txtname + " has been saved!", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
toast.show();
Intent i = new Intent(getApplicationContext(), OpenCalculator.class);
startActivity(i);
} catch (IOException ioe)
{
Toast toast = Toast.makeText(getApplicationContext(), "Sorry, your device has no SD card inserted, ITax saves files only on SD cards OR you don't have the destination folder, \"download\"", Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
toast.show();
ioe.printStackTrace()
;}
}
});
btn_warning.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent i = new Intent(getApplicationContext(), SalaryNoteMonthly.class);
startActivity(i);
}
});
btn_compute.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
final EditText net_salary = (EditText) findViewById(R.id.et_net_monthly);
final TextView tax_due = (TextView) findViewById(R.id.txt_taxdue);
double netSalary, taxDue, rate = 0, exemption = 0, subtrahend = 0, withRate, total;
ns = net_salary.getText().toString();
/* checks if textbox is blank, then make it to 0 */
if(ns.equals(""))
{
netSalary = 0;
Toast toast = Toast.makeText(getApplicationContext(), "Net Salary is blank.", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
toast.show();
}
else
{
netSalary = Double.parseDouble(ns);
}
/* Converting Net Salary to String with 2 decimal places */
n = String.format("%.2f", netSalary);
/* Single or Married with no dependent */
if ("SME".equals(civil_status)) {
if (netSalary >= 4167 && netSalary < 5000) {
rate = 0.05;
exemption = 0.00;
subtrahend = 4167;
} else if ((netSalary >= 5000) && (netSalary < 6667)) {
rate = 0.1;
exemption = 41.67;
subtrahend = 5000;
} else if ((netSalary >= 6667) && (netSalary < 10000)) {
rate = 0.15;
exemption = 208.33;
subtrahend = 6667;
} else if ((netSalary >= 10000) && (netSalary < 15833)) {
rate = 0.20;
exemption = 708.33;
subtrahend = 10000;
} else if ((netSalary >= 15833) && (netSalary < 25000)) {
rate = 0.25;
exemption = 1875.00;
subtrahend = 15833;
} else if ((netSalary >= 25000) && (netSalary < 45833)) {
rate = 0.30;
exemption = 4166.67;
subtrahend = 25000;
} else if (netSalary >= 45833) {
rate = 0.32;
exemption = 10416.67;
subtrahend = 45833;
}
}
/* Single or Married with 1 Dependent */
if ("SM1".equals(civil_status)) {
if ((netSalary >= 6250) && (netSalary < 7083)) {
rate = 0.05;
exemption = 0.00;
subtrahend = 6250;
} else if ((netSalary >= 7083) && (netSalary < 8750)) {
rate = 0.1;
exemption = 41.67;
subtrahend = 7083;
} else if ((netSalary >= 8750) && (netSalary < 12083)) {
rate = 0.15;
exemption = 208.33;
subtrahend = 8750;
} else if ((netSalary >= 12083) && (netSalary < 17917)) {
rate = 0.20;
exemption = 708.33;
subtrahend = 12083;
} else if ((netSalary >= 17917) && (netSalary < 27083)) {
rate = 0.25;
exemption = 1875.00;
subtrahend = 17917;
} else if ((netSalary >= 27083) && (netSalary < 47917)) {
rate = 0.30;
exemption = 4166.67;
subtrahend = 27083;
} else if (netSalary >= 47917) {
rate = 0.32;
exemption = 10416.67;
subtrahend = 47917;
}
}
/* Single or Married with 2 Dependents */
if ("SM2".equals(civil_status)) {
if ((netSalary >= 8333) && (netSalary < 9167)) {
rate = 0.05;
exemption = 0.00;
subtrahend = 8333;
} else if ((netSalary >= 9167) && (netSalary < 10833)) {
rate = 0.1;
exemption = 41.67;
subtrahend = 9167;
} else if ((netSalary >= 10833) && (netSalary < 14167)) {
rate = 0.15;
exemption = 208.33;
subtrahend = 10833;
} else if ((netSalary >= 14167) && (netSalary < 20000)) {
rate = 0.20;
exemption = 708.33;
subtrahend = 14167;
} else if ((netSalary > 20000) && (netSalary < 29167)) {
rate = 0.25;
exemption = 1875.00;
subtrahend = 20000;
} else if ((netSalary >= 29167) && (netSalary < 50000)) {
rate = 0.30;
exemption = 4166.67;
subtrahend = 29167;
} else if (netSalary >= 50000) {
rate = 0.32;
exemption = 10416.67;
subtrahend = 50000;
}
}
/* Single or Married with 3 Dependents */
if ("SM3".equals(civil_status)) {
if ((netSalary >= 10417) && (netSalary < 11250)) {
rate = 0.05;
exemption = 0.00;
subtrahend = 10417;
} else if ((netSalary >= 11250) && (netSalary < 12917)) {
rate = 0.1;
exemption = 41.67;
subtrahend = 11250;
} else if ((netSalary >= 12917) && (netSalary < 16250)) {
rate = 0.15;
exemption = 208.33;
subtrahend = 12917;
} else if ((netSalary >= 16250) && (netSalary < 22083)) {
rate = 0.20;
exemption = 708.33;
subtrahend = 16250;
} else if ((netSalary >= 22083) && (netSalary < 31250)) {
rate = 0.25;
exemption = 1875.00;
subtrahend = 22083;
} else if ((netSalary >= 31250) && (netSalary < 52083)) {
rate = 0.30;
exemption = 4166.67;
subtrahend = 31250;
} else if (netSalary >= 52083) {
rate = 0.32;
exemption = 10416.67;
subtrahend = 52083;
}
}
/* Single or Married with 4 Dependents */
if ("SM4".equals(civil_status)) {
if ((netSalary >= 12500) && (netSalary < 13333)) {
rate = 0.05;
exemption = 0.00;
subtrahend = 12500;
} else if ((netSalary >= 13333) && (netSalary < 15000)) {
rate = 0.1;
exemption = 41.67;
subtrahend = 13333;
} else if ((netSalary >= 15000) && (netSalary < 18333)) {
rate = 0.15;
exemption = 208.33;
subtrahend = 15000;
} else if ((netSalary >= 18333) && (netSalary < 24167)) {
rate = 0.20;
exemption = 708.33;
subtrahend = 18383;
} else if ((netSalary >= 24167) && (netSalary < 33333)) {
rate = 0.25;
exemption = 1875.00;
subtrahend = 24167;
} else if ((netSalary >= 33333) && (netSalary < 54167)) {
rate = 0.30;
exemption = 4166.67;
subtrahend = 33333;
} else if ((netSalary >= 54167)) {
rate = 0.32;
exemption = 10416.67;
subtrahend = 54167;
}
}
total = netSalary - subtrahend;
withRate = total * rate;
taxDue = withRate + exemption;
td = String.format("%.2f",taxDue);
e = String.format("%.2f", exemption);
s = String.format("%.2f", subtrahend);
r = String.format("%.2f", rate);
to = String.format("%.2f", total);
wr = String.format("%.2f", withRate);
/*Place the value in text view*/
tax_due.setText("Php " + td);
/*BREAK DOWN*/
final TextView tax_1 = (TextView) findViewById(R.id.txt_1);
final TextView tax_2 = (TextView) findViewById(R.id.txt_2);
final TextView tax_3 = (TextView) findViewById(R.id.txt_3);
final TextView tax_4 = (TextView) findViewById(R.id.txt_4);
tax_1.setText("> Net Salary (" + n + ") - Lower Limit (" + s + ") = " + to );
tax_2.setText("> " + to + " * Tax Rate (" + r + ") = " + wr);
tax_3.setText("> Exemption (" + e + ") + " + wr + " = " + td);
tax_4.setText("> Total Tax Due: " + td);
btn_show.setVisibility(1);
btn_save.setVisibility(1);
}
});
btn_save.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
btn_confirm.setVisibility(1);
et_txtfile.setVisibility(1);
txt_name.setVisibility(1);
}
});
btn_show.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
final TextView tax_1 = (TextView) findViewById(R.id.txt_1);
final TextView tax_2 = (TextView) findViewById(R.id.txt_2);
final TextView tax_3 = (TextView) findViewById(R.id.txt_3);
final TextView tax_4 = (TextView) findViewById(R.id.txt_4);
tax_1.setVisibility(1);
tax_2.setVisibility(1);
tax_3.setVisibility(1);
tax_4.setVisibility(1);
}
});
}
@Override
public void onBackPressed()
{
Intent i = new Intent(getApplicationContext(), OpenChoices.class);
startActivity(i);
}
}
これがlogcatです:
〜チャンネルは回復不能に壊れており、処分されます!11-15 21:37:17.735:ERROR / InputDispatcher(157):不明な入力チャネルの偽の受信コールバックを受信しました。fd = 183、events = 0x9 11-15 21:37:57.894:ERROR / Trace(1113):トレースファイルを開くときにエラーが発生しました:そのようなファイルまたはディレクトリはありません(2)11-15 21:38:27.525:ERROR / Trace(1154 ):トレースファイルを開くときにエラーが発生しました:そのようなファイルまたはディレクトリはありません(2)11-15 21:38:32.645:ERROR / ThrottleService(157):onPollAlarm中に問題が発生しました:java.lang.IllegalStateException:統計の解析に問題があります:java.io.FileNotFoundException :/ proc / net / xt_qtaguid / iface_stat_all:オープンに失敗しました:ENOENT(そのようなファイルまたはディレクトリはありません)11-15 21:40:06.105:ERROR / AndroidRuntime(1154):致命的な例外:main java.lang.RuntimeException:開始できませんアクティビティComponentInfo{com.example.ITax/ com.example.ITax.MonthlyComputation}:java.lang.ClassCastException:553)at dalvik.system.NativeStart.main(Native Method)原因:java.lang.ClassCastException:android.widget.TextViewをcom.example.ITax.MonthlyComputation.onCreate(MonthlyComputation。 java:47)at android.app.Activity.performCreate(Activity.java:5008)at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)。 .. 11 more 11-15 21:40:08.395:ERROR / InputDispatcher(157):channel '413830d8 com.example.ITax / com.example.ITax.OpenChoices(server)'〜Channelは回復不能に壊れており、破棄されます!11-15 21:40:08.475:ERROR / InputDispatcher(157):不明な入力チャネルの偽の受信コールバックを受信しました。fd = 197、events = 0x9 11-15 21:43:10.085: