Crusty, blikani jsem rozchodil, nicmene mi blika "TT" na nespravnem miste, pomuzes mi to dat na misto
jedne z tech hvezidcek ??
Jak jsi na tom financne, kdybys chtel poslu ti tech par stovek za Tvoji ochotu, bez ni bych to nedal.
Pomuze Ti to ?
Kód: Vybrat vše
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom|fill_horizontal"
android:layout_span="@integer/material_motion_duration_long_2"
android:background="#FFFFFF"
android:backgroundTint="#FFFFFF"
android:backgroundTintMode="multiply"
android:foregroundGravity="fill_horizontal|center_horizontal"
android:foregroundTint="@color/purple_200"
android:foregroundTintMode="multiply"
android:requiresFadingEdge="vertical"
android:scrollbarDefaultDelayBeforeFade="10"
android:visibility="visible">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="4"
android:layout_columnWeight="12"
android:accessibilityLiveRegion="none"
android:orientation="vertical">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"></TableLayout>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#1DE9B6"
android:onClick="click2"
android:text="Generate"
android:textColor="#000000"
android:textSize="10dp" />
<EditText
android:id="@+id/simpleEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:digits="10"
android:hint="Number of coalitions appear here"
android:inputType="text"
android:minHeight="48dp"
android:textColor="#FF0000" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="12"
android:layout_columnWeight="12"
android:accessibilityLiveRegion="none"
android:inputType="textCapCharacters"
android:orientation="horizontal">
<Button
android:id="@+id/button4"
android:layout_width="25mm"
android:layout_height="wrap_content"
android:foregroundTint="#FF0000"
android:foregroundTintMode="src_over"
android:onClick="click4"
android:scrollbarDefaultDelayBeforeFade="4"
android:text="Increase"
android:textSize="11dp" />
<Button
android:id="@+id/button7"
android:layout_width="25mm"
android:layout_height="wrap_content"
android:foregroundTint="#FF0000"
android:foregroundTintMode="src_over"
android:onClick="click7"
android:scrollbarDefaultDelayBeforeFade="4"
android:text="Decrease"
android:textSize="11dp" />
</LinearLayout>
<Button
android:id="@+id/button5"
android:layout_width="50mm"
android:layout_height="wrap_content"
android:backgroundTint="#00E5FF"
android:backgroundTintMode="add"
android:onClick="click5"
android:text="Power indices" />
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:text="Shapley and Banzhaf" />
<TextView
android:id="@+id/tvMarque"
android:layout_width="50mm"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:layout_gravity="center_horizontal"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:padding="5dp"
android:textSize="16sp"
android:text="AHA"
android:visibility="visible" />
<TextView
android:id="@+id/tvMarque2"
android:layout_width="24mm"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textColor="#00E5FF"
android:layout_gravity="center_horizontal"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:padding="15dp"
android:textSize="12sp"
android:text="AHA2"
android:visibility="visible" />
<TextView
android:id="@+id/blink"
android:layout_width="50mm"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:layout_gravity="center_horizontal"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:padding="5dp"
android:textSize="16sp"
android:text="TT"
android:visibility="visible" />
</LinearLayout>
</ScrollView>
Kód: Vybrat vše
package com.example.tablelayout6;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.icu.text.MeasureFormat;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.Spannable;
import android.view.MotionEvent;
import android.view.View;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TableRow;
import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.TableLayout;
import android.text.TextUtils;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import java.lang.StringBuilder;
public class MainActivity extends AppCompatActivity {
public boolean g=true;
public Integer N=1;
public String a="2";
private EditText editText1;
private EditText linear;
private Integer[] hodnoty =new Integer[10];
private String[] koal=new String[10];
private float[] shap=new float[10];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
View blink = findViewById(R.id.blink);
blink.setVisibility(blink.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
handler.postDelayed(this, 1000);
}
}, 1000);
}
public boolean iswinning(Integer J,int ii) {
return true;
}
public Integer fact (Integer f) {
if (f==0) return 1;
else return f*fact((Integer) (f-1));
}
//T pocetHracu
public Integer[] stringToArray(String binary) {
Integer[] arrayOfPLayers=new Integer[binary.length()];
for(int i=0;i<binary.length();i++) {
arrayOfPLayers[i]=Integer.parseInt("" + binary.charAt(i));
}
return arrayOfPLayers;
}
//N je pocet koalici
public void click5(View view) {
int pocetHracu=Integer.toBinaryString(N-1).length();
Integer[][] koalice=new Integer[N][pocetHracu];
Integer[][] koalice2=new Integer[N][pocetHracu];
Integer[][] koalice3=new Integer[N][pocetHracu];
for (Integer ith=0;ith<N;ith++) {
for(Integer T=0;T<pocetHracu;T++) {
String StringPadded=stf(Integer.toBinaryString(ith),pocetHracu-Integer.toBinaryString(ith).length());
koalice[ith][T]=stringToArray(StringPadded)[T];
koalice2[ith][T]=stringToArray(StringPadded)[T];
koalice3[ith][T]=stringToArray(StringPadded)[T];
}
}
float[] shap=new float[pocetHracu];
float[] vyhryKoalici = new float[N];
Integer[] isSwing=new Integer[pocetHracu];
for (int i=0; i<N;i++) {
editText1 = (EditText) findViewById(330+i);
String a=editText1.getText().toString();
float f1 = Float.parseFloat(a);
vyhryKoalici[i]=f1;
}
Integer[] kolikJeSwingu= new Integer[pocetHracu];
String S="";
String kde="j";
Integer jth;
for (int p = 0; p < pocetHracu; p++) {
isSwing[p] =0;
kolikJeSwingu[p]=N;
}
// Integer swingove2=pocetHracu*N;
Integer bool=1;
Integer canBanzhaf=1;
for(Integer contr=0;contr<N;contr++)
{
if(vyhryKoalici[contr]!=0 && vyhryKoalici[contr]!=1) {
canBanzhaf=0;
}
}
for(Integer T=0;T<pocetHracu;T++) {
for (Integer ith = 0; ith < N; ith++) {
bool = 1;
//vyhryKoalici[ith];
//musis najit jth<N pro ktere koalice3[jth]=S-ith
if ((koalice[ith][T] == 1) && (vyhryKoalici[ith]==1)) {
koalice3[ith][T] = 0;
for (jth = 0; jth < N; jth++) {
for (Integer k = 0; k < pocetHracu; k++)
{
//if (k != T && koalice[ith][k] != koalice3[jth][k]) {
if ((k != T) && (koalice[ith][k] != koalice3[jth][k])) {
bool = 0;
// swingove2--;
kde+="\nk"+k.toString()+"T"+T.toString()+">";
}
}
kde+="\njth"+jth.toString()+"ith"+ith.toString()+"T"+T.toString();
//(vyhryKoalici[jth]
if ((vyhryKoalici[jth]==0) && (bool == 1)) {
isSwing[T]++;
}
bool=1;
}
koalice3[ith][T]=1;
bool=1;
}
}
}
//kolikJeSwingu(Integer TmaSwing, Integer pocetHracu, Integer pocetKoalici,
// Integer[][] koal, Integer[] koalicePriKtereJeSwing, float[] vyhryKoal)
for (Integer ith = 0; ith < N; ith++) {
for(Integer T=0;T<pocetHracu;T++) {
//isSwingBool(Integer kteraKoalice, Integer TmaSwing, Integer pocetHracu, Integer pocetKoalici,
// Integer[][] koal, Integer[] koalicePriKtereJeSwing, float[] vyhryKoal) {
// kolikJeSwingu[T]+=kolikJeSwingu(T, pocetHracu, N,
// koalice, koalice[ith],vyhryKoalici);
if (koalice[ith][T] == 1) {
koalice2[ith][T] = 0;
for (jth = 0; jth < N; jth++) {
bool = 1;
for (int k = 0; k < pocetHracu; k++) {
if (k != T && koalice[ith][k] != koalice2[jth][k]) {
bool = 0;
}
}
int bool2=0;
koalice2[ith][T] = 1;
if (vyhryKoalici[ith] == 1 && vyhryKoalici[jth] == 0) {
for (int k = 0; k < pocetHracu; k++) {
if (koalice[ith][k] != koalice2[jth][k]) {
bool2++;
}
}
// if(bool2==1) {
// isSwing[T]++;
// }
}
koalice2[ith][T] = 1;
Integer t = 0;
for (int p = 0; p < pocetHracu; p++) {
t += koalice[ith][p];
}
// Integer[] isSwing=new Integer[pocetHracu];
if (bool == 1) {
shap[T] += (float) ((float) fact(t - 1) * fact(pocetHracu - t) / (float) (fact(pocetHracu)) * (float) (vyhryKoalici[ith] - vyhryKoalici[jth]));
}
}
}
}
}
S+="here";
String T2="";
T2+="banzhaf";
Integer swingove=0;
for(int p=0;p<pocetHracu;p++) {
swingove+=isSwing[p];
}
String strPokus="";
if(canBanzhaf==1) {
strPokus = "banzhaf ";
} else {
strPokus="banzhaf err ";
}
float[] banzh=new float[pocetHracu];
for(int p=0;p<pocetHracu;p++)
{
banzh[p]=(float) isSwing[p]/(float) swingove;
}
String strPokus2="shap ";
for(int i=0;i<pocetHracu;i++) {
// S+=(" "+String.valueOf(shap[i]));
strPokus2+=String.format("%.2f ",shap[i]);
strPokus+=String.format("%.2f ",banzh[i]);
}
// tv6.setText(strPokus2+"\n"+strPokus+"\nswing"+isSwing[0]+"swingPrvni:"+isSwing[1]+"\nH"+swingove);
TextView tv6 = (TextView) findViewById(R.id.tvMarque);
// tv6.setSingleLine(true);
tv6.setMarqueeRepeatLimit(-1);
tv6.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv6.setSelected(true);
tv6.setText(strPokus2+"\n"+strPokus);
TextView tv7 = (TextView) findViewById(R.id.tvMarque2);
tv7.setSingleLine(true);
tv7.setMarqueeRepeatLimit(-1);
tv7.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv7.setSelected(true);
// tv7.setText(" * * * * * * * * * ");
// tv7.setText(Html.fromHtml(" * * * * * <b><p style=color:yellow;>*</p></b> * * * "));
// tv7.setText(Html.fromHtml("**<p style=color:green;> * T*</p>\n<ul><li>* * * <p style=color:green;>*</p> <p style=color:red;>*</p>* * * </li></ul>"));
tv7.setText(Html.fromHtml("**<p style=color:green> * T*</p>\n<ul><li>* * * <p style=color:green;>*</p> <p style=color:red;>*</p>* * * </li></ul>"));
// String html = "<html><body><p>Hello world</p></body></html>";
// String baseUrl = "https://example.com/";
// WebView mWebView;
// mWebView.loadDataWithBaseURL(baseUrl, html, "text/html", null, baseUrl);
//tv6.setText("11bbbb"+"bDDDDDDDjjjjjjjjjjppppppppppppppDDbbbbbbbbbb");
// TextView textView=(TextView)findViewById(R.id.text_test);
/* tv6.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv6.setSingleLine(true);
tv6.setMarqueeRepeatLimit(-1);
tv6.setFocusableInTouchMode(true);
tv6.setFocusable(true);
*/
/* TextView txt = new TextView(this);
txt.setText("This is the infinite marquee");
txt.setEllipsize(TextUtils.TruncateAt.MARQUEE);
txt.setSingleLine(true);
txt.setMarqueeRepeatLimit(-1);
txt.setSelected(true);
*/
}
public void click4(View view) {
//
if (g) {
linear = (EditText) findViewById(R.id.simpleEditText);
if (N == 1) {
linear.setText("1");
}
String a = linear.getText().toString();
N = Integer.parseInt(a);
N++;
linear.setText(N.toString());
}
}
public void click7(View view) {
if (g) {
//
linear = (EditText) findViewById(R.id.simpleEditText);
if (N == 0 || N == 1) {
linear.setText("1");
}
String a = linear.getText().toString();
N = Integer.parseInt(a);
if (N > 1) N--;
linear.setText(N.toString());
}
}
public String stf(String a,Integer l) {
if(l==0) { return a; }
l--;
return stf("0"+a,l);
}
public void click2(View view) {
if (g) {
g = false;
String col1;
String col2;
// String playerChanged;
TableLayout tl = (TableLayout) findViewById(R.id.tableLayout1);
EditText editText = (EditText) findViewById(R.id.simpleEditText);
TableRow row = new TableRow(this);
TextView tv = new TextView(this);
TextView c = new TextView(this);
//EditText etUserInfoNewValue = (EditText)findViewById(R.id.simpleEditText);
// a = editText.getText().toString();
tv.setId(202);
tv.setText("This is text");
//
tl.addView(row);
row.addView(tv);
int sf = Integer.toBinaryString(N - 1).length();
for (int x = 0; x < N; x++) {
//String.format("%010d",(
String jl = Integer.toBinaryString(x);
String jl2 = stf(jl, sf - jl.length());
//koal[x]=jl2;
col1 = "(" + x + ")" + jl2;
// col1 = "(" + x + ")"+Integer.toBinaryString(x);
col2 = "1";
//col3 = "(" + x + ") Column 3";
//col4 = "(" + x + ") Column 4";
TableRow newRow = new TableRow(this);
TextView column1 = new TextView(this);
TextView column2 = new TextView(this);
EditText editText1 = new EditText(this);
editText1.setId(330 + x);
// String stringAnswer = editText1.getText().toString();
TextView column3 = new TextView(this);
// TextView column4 = new TextView(this);
editText1.setText("0 ");
column1.setText(col1);
column1.setText(col1);
column2.setText(col2);
//column3.setText(col3);
//column4.setText(col4);
// column1.setText(stringAnswer);
newRow.addView(column1);
newRow.addView(editText1);
newRow.addView(column3);
// newRow.addView(column4);
tl.addView(newRow, new TableLayout.LayoutParams());
}
}
}
}