私は自分のゲームコレクションプロジェクトに取り組んでいます。まあ、それは私が仕上げて自分自身を使うつもりの学校プロジェクトでした。私はそれぞれのアクティビティとJavaページをコピーして貼り付け、毎回ゲームの名前だけを変更していますが、スクロールしています。マニフェストとメインアクティビティのページに同じ手順でいくつかの行を追加する必要がありますが、それほど長くはありません。私は、プログラムやバッチファイルがあるかどうか、またはゲームの名前だけを変更するコードを生成する簡単なプログラムを書くことができる方法を知りたかったのですが、その場所にvarを追加して、コード全体の名前。以下は、abadoxという名前のゲームのクラスの1つです。今私がやっているのは、このファイルに対処しているだけです。私は、このコードをコピーして貼り付けて、数千回コピーして、すべてのゲームを手に入れて時間を無駄にする代わりに、これを行う簡単な方法があるかどうかを知りたかっただけです。私はおそらくいくつかのコードが間違っている私はかなり自分自身を教えていると私は私が望むように働いている。私はデータベースを使用しようとしましたが、正しく動作させる方法を理解できませんでした。私はデータベースを使用してファイルを引っ張ったかもしれませんが、私はそれを知っていますが、それを行う方法がわかりませんでした。Android Studio 1単語の変更だけで新しいアクティビティを作成する方法はありますか?
public class Abadox extends Activity {
EditText abadoxCopies;
EditText abadoxBar;
EditText abadoxCom;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_abadox);
abadoxCopies = (EditText) findViewById(R.id.txtabadoxCopies);
abadoxBar = (EditText) findViewById(R.id.txtabadoxBor);
abadoxCom = (EditText) findViewById(R.id.txtabadoxCom);
SharedPreferences sharedPref = getSharedPreferences("abadox", 0);
String strabadoxcopies = sharedPref.getString("abadoxcopies", "");
String strabadoxbarrow = sharedPref.getString("abadoxbarrow", "");
String strabadoxcomment = sharedPref.getString("abadoxcomment", "");
abadoxCopies.setText(strabadoxcopies);
abadoxBar.setText(strabadoxbarrow);
abadoxCom.setText(strabadoxcomment);
}
//Save files
public void saveInfo(View view) {
SharedPreferences sharedPref = getSharedPreferences("abadox", 0);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("abadoxcopies", abadoxCopies.getText().toString());
editor.putString("abadoxbarrow", abadoxBar.getText().toString());
editor.putString("abadoxcomment", abadoxCom.getText().toString());
editor.apply();
editor.commit();
Intent intent = new Intent(this, NES.class);
startActivity(intent);
}
抽象クラスを作成しますか? – EpicPandaForce