Advertisement
Guest User

Horse

a guest
Jan 22nd, 2018
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. package com.example.android.horserace;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.os.Build;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.LinearLayout;
  11. import android.widget.SeekBar;
  12. import android.widget.TextView;
  13. import android.widget.Toast;
  14.  
  15. public class Race extends AppCompatActivity {
  16.     Context context;
  17.     LinearLayout layout;
  18.     Button start;
  19.  
  20.     @Override
  21.     protected void onCreate(Bundle savedInstanceState) {
  22.         super.onCreate(savedInstanceState);
  23.         setContentView(R.layout.race);
  24.         setPointer();
  25.     }
  26.  
  27.     private void setPointer() {
  28.         this.context = this;
  29.         start=findViewById(R.id.start);
  30.         layout = findViewById(R.id.layoutHorses);
  31.         Intent intent = getIntent();
  32.         int horses = intent.getIntExtra("Horses", 1);
  33.  
  34.         for (int i = 1; i <= horses; i += 1) {
  35.             LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
  36.                     LinearLayout.LayoutParams.MATCH_PARENT,
  37.                     LinearLayout.LayoutParams.WRAP_CONTENT);
  38.  
  39.             params.setMargins(10, 50, 10, 10);
  40.             final SeekBar seekBar = new SeekBar(context);
  41.             seekBar.setLayoutParams(params);
  42.             seekBar.setId(1000 + i);
  43.             layout.addView(seekBar);
  44.  
  45.  
  46.  
  47.  
  48.  
  49.         }
  50. //findViewById(getT)
  51.         //Thread thread = new Thread(new Horse((SeekBar) findViewById(1001)));
  52.  
  53.  
  54.  //       thread.start();
  55.  
  56.     }
  57.  
  58.  
  59. }
  60.  
  61.  
  62.  
  63. <LinearLayout android:layout_width="match_parent"
  64.     android:layout_height="match_parent"
  65.     android:orientation="vertical"
  66.     xmlns:android="http://schemas.android.com/apk/res/android" >
  67.  
  68.  
  69.     <LinearLayout
  70.         android:layout_width="match_parent"
  71.         android:layout_height="wrap_content"
  72.         android:id="@+id/layoutHorses"
  73.         android:orientation="vertical"
  74.         android:gravity="center_vertical"
  75.     />
  76.  
  77. <Button
  78.     android:layout_width="wrap_content"
  79.     android:layout_height="wrap_content"
  80.     android:text="START"
  81.     android:id="@+id/start"/>
  82.  
  83. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement