Advertisement
Guest User

Untitled

a guest
Feb 12th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:padding="20dp">
  6.  
  7. <RelativeLayout
  8. android:id="@+id/layoutLogin"
  9. android:layout_width="match_parent"
  10. android:layout_height="match_parent">
  11.  
  12.  
  13.  
  14.  
  15. <EditText
  16. android:id="@+id/edtUserName"
  17. android:layout_width="match_parent"
  18. android:layout_height="wrap_content"
  19. android:hint="Eneter user name"
  20.  
  21.  
  22. />
  23.  
  24. <EditText
  25. android:id="@+id/edtUserPassword"
  26. android:layout_width="match_parent"
  27. android:layout_height="wrap_content"
  28. android:layout_below="@id/edtUserName"
  29. android:hint="Eneter user Password"
  30.  
  31. />
  32.  
  33. <Button
  34. android:id="@+id/btnLogin"
  35. android:layout_width="match_parent"
  36. android:layout_height="wrap_content"
  37. android:layout_alignParentBottom="true"
  38.  
  39. android:text="Login"
  40.  
  41.  
  42. />
  43.  
  44. </RelativeLayout>
  45. <RelativeLayout
  46.  
  47.  
  48. android:id="@+id/layoutProfile"
  49. android:layout_width="match_parent"
  50. android:layout_height="match_parent"
  51. android:visibility="gone">
  52.  
  53. <ImageView
  54.  
  55. android:id="@+id/ImgUserProfile"
  56. android:layout_width="wrap_content"
  57. android:layout_height="wrap_content"
  58. android:layout_centerHorizontal="true"
  59. android:layout_margin="20dp"
  60. android:src="@mipmap/ic_launcher"
  61.  
  62. />
  63.  
  64.  
  65. <LinearLayout
  66.  
  67. android:id="@+id/Namee"
  68. android:layout_width="match_parent"
  69. android:layout_height="wrap_content"
  70. android:layout_below="@id/ImgUserProfile">
  71.  
  72. <TextView
  73. android:layout_width="match_parent"
  74. android:layout_height="wrap_content"
  75. android:layout_below="@id/ImgUserProfile"
  76. android:layout_weight="3"
  77. android:text="Name: " />
  78.  
  79. <EditText
  80. android:layout_width="match_parent"
  81. android:layout_height="wrap_content"
  82. android:layout_weight="1"
  83.  
  84. />
  85. </LinearLayout>
  86.  
  87. <LinearLayout
  88.  
  89. android:id="@+id/LNamee"
  90. android:layout_width="match_parent"
  91. android:layout_height="wrap_content"
  92. android:layout_below="@id/Namee">
  93.  
  94. <TextView
  95. android:id="@+id/edtN"
  96. android:layout_width="match_parent"
  97. android:layout_height="wrap_content"
  98. android:layout_weight="3"
  99. android:text="LastName: " />
  100.  
  101. <EditText
  102. android:layout_width="match_parent"
  103. android:layout_height="wrap_content"
  104. android:layout_weight="1"
  105.  
  106. />
  107.  
  108.  
  109. </LinearLayout>
  110.  
  111. <LinearLayout
  112.  
  113. android:id="@+id/Addres"
  114. android:layout_width="match_parent"
  115. android:layout_height="wrap_content"
  116. android:layout_below="@id/LNamee">
  117.  
  118. <TextView
  119. android:layout_width="match_parent"
  120. android:layout_height="wrap_content"
  121. android:layout_weight="3"
  122. android:text="Addres: " />
  123.  
  124. <EditText
  125. android:layout_width="match_parent"
  126. android:layout_height="wrap_content"
  127. android:layout_weight="1"
  128.  
  129. />
  130.  
  131.  
  132. </LinearLayout>
  133.  
  134. <LinearLayout
  135. android:id="@+id/Phoneid"
  136. android:layout_width="match_parent"
  137. android:layout_height="wrap_content"
  138. android:layout_below="@id/Addres">
  139.  
  140. <TextView
  141. android:layout_width="match_parent"
  142. android:layout_height="wrap_content"
  143. android:layout_weight="3"
  144. android:text="Phone: " />
  145.  
  146. <EditText
  147. android:layout_width="match_parent"
  148. android:layout_height="wrap_content"
  149. android:layout_weight="1"
  150.  
  151. />
  152.  
  153.  
  154. </LinearLayout>
  155.  
  156.  
  157. </RelativeLayout>
  158.  
  159. </RelativeLayout>
  160.  
  161.  
  162.  
  163. MainActivity
  164. package com.example.student.myapplication;
  165.  
  166. import android.app.ListActivity;
  167. import android.support.v7.app.AppCompatActivity;
  168. import android.os.Bundle;
  169. import android.view.View;
  170. import android.widget.ArrayAdapter;
  171. import android.widget.Button;
  172. import android.widget.EditText;
  173. import android.widget.ListView;
  174. import android.widget.RelativeLayout;
  175. import android.widget.Toast;
  176.  
  177. public class MainActivity extends AppCompatActivity {
  178.  
  179. //init
  180.  
  181. Button btnLogin;
  182. EditText editTextUserName,editTextUserPassword;
  183.  
  184. RelativeLayout layoutProfil,layoutLogin;
  185. ListView lista;
  186.  
  187. @Override
  188. protected void onCreate(Bundle savedInstanceState) {
  189. super.onCreate(savedInstanceState);
  190. setContentView(R.layout.slusateli);
  191.  
  192.  
  193. // initComponents();
  194. //setComponents();
  195. lista=(ListView) findViewById(R.id.listaSlusateli);
  196. String [] slusateli=new String[]{
  197.  
  198. "Ilir",
  199. "Besar",
  200. "Igor",
  201. "Eljesa",
  202. "Stefan",
  203. "Ilija",
  204. "Jovanka",
  205. "Stefan"
  206. };
  207.  
  208. ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,slusateli);
  209. lista.setAdapter(adapter);
  210. }
  211.  
  212.  
  213. /*
  214. public void initComponents(){
  215. btnLogin=(Button) findViewById(R.id.btnLogin);
  216. editTextUserName =(EditText) findViewById(R.id.edtUserPassword);
  217. editTextUserPassword=(EditText) findViewById(R.id.edtUserPassword);
  218. layoutProfil=(RelativeLayout) findViewById(R.id.layoutProfile);
  219. layoutLogin= (RelativeLayout) findViewById(R.id.layoutLogin);
  220. lista=(ListView) findViewById(R.id.listaSlusateli);
  221. }
  222. */
  223. public void setComponents(){
  224.  
  225. btnLogin.setOnClickListener(new View.OnClickListener() {
  226. @Override
  227. public void onClick(View view) {
  228.  
  229. String msg="Yoou click me"+editTextUserPassword.getText()+editTextUserName.getText();
  230. Toast.makeText(MainActivity.this,"You click me",Toast.LENGTH_SHORT).show();
  231.  
  232. layoutLogin.setVisibility(View.GONE);
  233. layoutProfil.setVisibility(View.VISIBLE);
  234.  
  235. }
  236. });
  237.  
  238.  
  239. btnLogin.setOnLongClickListener( view->
  240. {
  241. String msg="Yoou click me"+editTextUserPassword.getText()+editTextUserName.getText();
  242. Toast.makeText(MainActivity.this,"Onlong",Toast.LENGTH_SHORT).show();
  243. return false;
  244. }
  245.  
  246. );
  247.  
  248.  
  249. }
  250.  
  251. }
  252.  
  253.  
  254.  
  255. Slusateli
  256.  
  257. <?xml version="1.0" encoding="utf-8"?>
  258. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  259. android:orientation="vertical" android:layout_width="match_parent"
  260. android:layout_height="match_parent">
  261.  
  262. <ListView
  263.  
  264. android:id="@+id/listaSlusateli"
  265. android:layout_width="match_parent"
  266. android:layout_height="match_parent"
  267. android:dividerHeight="1dp"
  268. >
  269.  
  270.  
  271.  
  272. </ListView>
  273.  
  274. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement