Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.horserace;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Build;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.LinearLayout;
- import android.widget.SeekBar;
- import android.widget.TextView;
- import android.widget.Toast;
- public class Race extends AppCompatActivity {
- Context context;
- LinearLayout layout;
- Button start;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.race);
- setPointer();
- }
- private void setPointer() {
- this.context = this;
- start=findViewById(R.id.start);
- layout = findViewById(R.id.layoutHorses);
- Intent intent = getIntent();
- int horses = intent.getIntExtra("Horses", 1);
- for (int i = 1; i <= horses; i += 1) {
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- params.setMargins(10, 50, 10, 10);
- final SeekBar seekBar = new SeekBar(context);
- seekBar.setLayoutParams(params);
- seekBar.setId(1000 + i);
- layout.addView(seekBar);
- }
- //findViewById(getT)
- //Thread thread = new Thread(new Horse((SeekBar) findViewById(1001)));
- // thread.start();
- }
- }
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- xmlns:android="http://schemas.android.com/apk/res/android" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/layoutHorses"
- android:orientation="vertical"
- android:gravity="center_vertical"
- />
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="START"
- android:id="@+id/start"/>
- </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement