私はプログラミングの初心者ですので、私はこれを正しくやっているかどうか、あるいは簡単な方法があるかどうかを確認したいだけです。基本的に私が作成しているアプリは、異なるメジャーに必要なすべてのコースをリストする学校アプリです。このAndroidアプリのこれらの多くのクラスを作成する必要がありますか?
だから、開く画面では、学部と大学院2つのボタンがあります。次の画面には、卒業生または学年のすべてのメジャーが表示されます。これは、ユーザーが選択した1つのアカウントをクリックした後、アカウントをクリックした人が会計専攻のすべてのコースをリストします。私の質問は、私は各コースとメジャーのための別のクラスを作成する必要がありますか?以下は私がやっているコードです。
package Class.Review;
import Class.Review.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.content.Intent;
public class ClassReviewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button Undergrad = (Button) findViewById(R.id.BUNGrad);
Undergrad.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Intent myIntent =
new Intent(view.getContext(), undergrad.class);
startActivityForResult(myIntent, 0);
}
});
}
}
次に、ユーザは、私は別のクラス
package Class.Review;
import Class.Review.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.TextView;
import android.content.Intent;
public class undergrad extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.undergrad);
setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Intent replyIntent = new Intent();
setResult(RESULT_OK, replyIntent);
finish();
}
});
}
private void setOnClickListener(OnClickListener onClickListener) {
// TODO Auto-generated method stub
Button Accounting = (Button) findViewById(R.id.Accounting);
Accounting.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Intent myIntent =
new Intent(view.getContext(), accounting.class);
startActivityForResult(myIntent, 0);
}
});
}
}
次に選択会計
package Class.Review;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.content.Intent;
public class accReview extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.accreview);
setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Intent replyIntent = new Intent();
setResult(RESULT_OK, replyIntent);
finish();
}
});
}
private void setOnClickListener(OnClickListener onClickListener) {
// TODO Auto-generated method stub
Button review = (Button) findViewById(R.id.reviews);
review.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Intent myIntent =
new Intent(view.getContext(), fundReview.class);
startActivityForResult(myIntent, 0);
}
});
}
}