Advertisement
Guest User

Header.java

a guest
Nov 29th, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. public class Header extends LinearLayout{
  2. private Context mContext;
  3. private ImageView btn12;
  4. private ImageView btn11;
  5.  
  6. public static RadioGroup radioGroup1 = Select.radioGroup;
  7.  
  8. private Button btn13;
  9. private Button btn14;
  10. String myString,un;
  11. private TextView topbar1;
  12. private String un1=questionsselection.un;
  13. private String myString1=questionsselection.myString;
  14. //private String value=Select.op1val;
  15. private RadioGroup rbgrp;
  16.  
  17.  
  18.  
  19. private static int i=1;
  20.  
  21. private int val=Integer.parseInt(un1);
  22. RadioButton numb1=Select.op1;
  23. RadioButton numb2=Select.op2;
  24. RadioButton numb3=Select.op3;
  25. RadioButton numb4=Select.op4;
  26. RadioButton numb5=Select.op5;
  27. String answer=null;
  28.  
  29. private SharedPreferences mPreferences2;
  30. public Header(Context context, AttributeSet attrs) {
  31.  
  32. super(context, attrs);
  33.  
  34. Log.i("un values",un1);
  35.  
  36. mContext = context;
  37.  
  38. String infService = Context.LAYOUT_INFLATER_SERVICE;
  39. LayoutInflater li;
  40.  
  41. li = (LayoutInflater) getContext().getSystemService(infService);
  42. li.inflate(R.layout.header, this, true);
  43.  
  44. ImageView topbar=(ImageView)findViewById(R.id.topbar);
  45. topbar1=(TextView)findViewById(R.id.number);
  46.  
  47. System.out.println(i);
  48. System.out.println(myString1);
  49.  
  50. btn11 = (ImageView) findViewById(R.id.next);
  51. btn11.setOnClickListener(mFooterListener);
  52. btn12 = (ImageView) findViewById(R.id.home);
  53. btn12.setOnClickListener(mhome);
  54.  
  55. if(myString1=="0")
  56. {
  57. topbar.setBackgroundResource(R.drawable.alltab);
  58. }
  59. else if(myString1=="1")
  60. {
  61. topbar.setBackgroundResource(R.drawable.medicinetab);
  62. }
  63. else if(myString1=="2")
  64. {
  65. topbar.setBackgroundResource(R.drawable.obgyntab);
  66. }
  67. else if(myString1=="3")
  68. {
  69. topbar.setBackgroundResource(R.drawable.pmchtab);
  70. }
  71. else if(myString1=="4")
  72. {
  73. topbar.setBackgroundResource(R.drawable.pediatricstab);
  74. }
  75. else if(myString1=="5")
  76. {
  77. topbar.setBackgroundResource(R.drawable.psychiatrytab);
  78. }
  79. else if(myString1=="6")
  80. {
  81. topbar.setBackgroundResource(R.drawable.surgerytab);
  82. }
  83.  
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. public void init() {
  92. // set init otherwise of ctor and call externally...
  93. }
  94.  
  95.  
  96. private OnClickListener mhome = new OnClickListener() {
  97.  
  98. public void onClick(View v) {
  99.  
  100.  
  101.  
  102. new AlertDialog.Builder(mContext).setTitle("MCCEE" )
  103. .setMessage("Do You Want To Quit The Test?")
  104. .setPositiveButton("OK", new DialogInterface.OnClickListener() {
  105. public void onClick(DialogInterface dialog, int whichButton) {
  106. //Write the intent here.
  107. mContext.startActivity( new Intent(mContext,homepage.class));
  108. // startActivity(reg2);
  109. }
  110.  
  111.  
  112. }).show();
  113.  
  114. // Context.startActivity(new Intent(mContext, homepage.class));
  115. }
  116. };
  117.  
  118. // Create an anonymous implementation of OnClickListener
  119. private OnClickListener mFooterListener = new OnClickListener() {
  120.  
  121. public void onClick(View v) {
  122.  
  123.  
  124. try
  125. {
  126. if(i<val)
  127. {
  128.  
  129.  
  130. int selected = radioGroup1.getCheckedRadioButtonId();
  131.  
  132. numb1 = (RadioButton) findViewById(selected);
  133. System.out.print("Get radiobutton id");
  134. System.out.print(numb1.getId());
  135. /*radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  136. public void onCheckedChanged(RadioGroup rg, int checkedId) {
  137. for(int i=0; i<rg.getChildCount(); i++) {
  138. RadioButton op11 = (RadioButton) rg.getChildAt(i);
  139. if(op11.getId() == checkedId) {
  140.  
  141. System.out.print(getId());
  142. //String text = btn.getText();
  143. // do something with text
  144.  
  145. }
  146. }
  147. }
  148. });
  149. */
  150.  
  151. //String value=Select.op1val;
  152.  
  153. // Log.i("111",value);
  154. System.out.println("valllll"+val);
  155. System.out.println("iii"+i);
  156. mContext.startActivity(new Intent(mContext, Select.class));
  157. i++;
  158.  
  159. System.out.println("after inc i"+i);
  160.  
  161. }
  162.  
  163.  
  164.  
  165. else
  166. {
  167. i=1;
  168. new AlertDialog.Builder(mContext).setTitle("MCCEE" )
  169. .setMessage("Test Completed")
  170.  
  171. .setPositiveButton("OK", new DialogInterface.OnClickListener() {
  172. public void onClick(DialogInterface dialog, int whichButton) {
  173. //Write the intent here.
  174. mContext.startActivity( new Intent(mContext,Analysis.class));
  175.  
  176. // startActivity(reg2);
  177. }
  178.  
  179. }).show();
  180.  
  181.  
  182. }
  183.  
  184. }
  185. catch(Exception e){
  186.  
  187. String err = (e.getMessage()==null)?"SD Card failed":e.getMessage();
  188. Log.e("sdcard-err2:",err);
  189.  
  190. }
  191. }
  192.  
  193.  
  194. };
  195.  
  196. }
  197.  
  198.  
  199.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement