Reputation: 1
I'm currently trying to program my first Android App.
It's supposed to be a Sudoku solver, but I'm not that far yet.
I kind of got stuck, because the App crashes when I try to click a Button.
The only Button that has an onClick
function by now is grid_11
, so I cut out the rest which isn't important.
I hope someone can tell me, what I'm doing wrong.
package com.example.sudokusolver;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.SeekBar;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button grid_11;
SeekBar seekBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
grid_11 = (Button)findViewById(R.id.grid_11);
seekBar = (SeekBar)findViewById(R.id.seekBar);
grid_11.setOnClickListener(this);
}
boolean solved = false;
@Override
public void onClick(View v){
if (solved == false){
switch(v.getId()){
case R.id.grid_11:
grid_11.setText(seekBar.getProgress());
}
}
}
}
Upvotes: 0
Views: 63
Reputation: 2522
Replace below code
grid_11.setText(String.valueOf(seekBar.getProgress()));
You can not set integer value into Button or Textview directly , you must to convert into String format.
Upvotes: 1