Rady a tipy pro vyvojpotize s vyvojem aplikace, uzivatelsky vstup

Moderátoři: mArtinko5MB, mArtinko5MB

max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

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="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="#00E5FF"
            android:backgroundTintMode="add"
            android:foregroundTint="#000000"
            android:onClick="click5"
            android:text="Power indices" />


        <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textCapCharacters"
            android:text="Shapley and Banzhaf" />

        <EditText
            android:id="@+id/editTextTextMultiLine"
            android:layout_width="match_parent"
            android:layout_height="284dp"
            android:layout_gravity="right"
            android:capitalize="sentences"
            android:clickable="true"
            android:cursorVisible="true"
            android:drawableBottom="@drawable/ic_launcher_background"
            android:ems="10"
            android:foregroundGravity="right"
            android:gravity="bottom|left" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="274dp"
            android:layout_height="159dp"
            android:gravity="bottom|right"
            android:inputType="textCapCharacters"
            android:text="TextView" />

    </LinearLayout>
</ScrollView>
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Nejak se nemohu dockat odpovedy nam muj dulezity problem. Mohl bys mi, Crusty, aspon sem hodit MWE (minimal working example)
toho MARQUEE ?

Ja zkusil toto dat do XMLka ale nic se nehybe

Kód: Vybrat vše

<TextView
            android:id="@+id/tvMarque"
            android:layout_width="wrap_content"
            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" />
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

funguje to jen pro texty delsi nez sirka TextView

v kodu je potreba volat
tvMargue.setSelected(true)

Kód: Vybrat vše

<TextView
        android:id="@+id/tvMarque"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@id/multi"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
        android:layout_gravity="center_horizontal"
        android:padding="5dp"
        android:textSize="16sp"
        android:text="Toto bude fungovat, jen pokud je text delsi, nez je sirka obrazovky, jinak se t horizontalne posouvat nebude."
        />
Nejak se nemohu dockat odpovedy nam muj dulezity problem
no google je jinak stale k dispozici :)
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Uz mi to jde, ale tlacitko "Power Indices" je ted pres celou sirku mobilu,coz je nemile.
Kdyz ho zkratim na 25mm, tak se to opet nehybe.
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

A jeste: proc toto se hybe
tv6.setText(strPokus2+"***"+strPokus+"***");

a toto nikoliv:

tv6.setText("11bbbb"+"bDDDDDDDDDbbbbbbbbbb");
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Uz mi to jde :palec:

Mam jeste dva dotazy k MARQUEE:

jak nastavim rychlost rotace a jak nastavit pocatek opakovani.
Tim myslim, zda existuje nejaky parametr, ktery by napriklad zaridil aby se dalsi cyklus zobrazil *ihned*
po skonceni predchozi casti nebo naopak az po uplnem skonceni predchozi casti. POsilam i svuj kod,
jak to tam mam napsane v MainActivity.java:

TextView tv7 = (TextView) findViewById(R.id.tvMarque2);
tv7.setSingleLine(true);
tv7.setMarqueeRepeatLimit(-1);
tv7.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv7.setSelected(true);
tv7.setText(" * * * * * * * * * ");

Ted se mi to zobrazuje asi po 2/3. Nikde se k tomu jak to zmenit nemohu dopatrat a jsem zvedav, zda to jde.
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

to netusim, jestli to takto nastavovat jde. Tohle slouzi spis jen jako pomucka, pro zobrazeni textu, ktery je delsi nez TextView v krem se zobrazuje.
Na nejake dalsi vychytavky uz si spis udelat svoje TextView, neco jako zde
https://stackoverflow.com/questions/897 ... -set-speed
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Crusty, mam jeste jeden pozadavek, je treba slozite programovani jak jsi uvedl v predchozim komentu k tomu, abych **jednu**
z techto zelenych hvezdicek udelal cervenou? Posilam .java i .xml:

Kód: Vybrat vše

TextView tv7 = (TextView) findViewById(R.id.tvMarque2);
        tv7.setSingleLine(true);
        tv7.setMarqueeRepeatLimit(-1);
        tv7.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        tv7.setSelected(true);
        tv7.setText("         * *            *          * *           *           *  *            *           ");

Kód: Vybrat vše

<TextView
            android:id="@+id/tvMarque2"
            android:layout_width="30mm"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:layout_gravity="center_horizontal"
            android:fadingEdge="horizontal"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:textColor="#00E5FF"
            android:padding="15dp"
            android:textSize="12sp"
            android:text="AHA2"
            android:visibility="visible" />
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

sice tak, jak je to popsano to nefunguje, sviti cervene `val` nicmene tato serednost splnila cil:

Kód: Vybrat vše

 tv7.setText(Html.fromHtml("**<p style=color:green;>  *&nbsp;*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Crusty, nevedel bys jeste proc to velke "Tecko" neblika, kdyz jsem mu dal tag

Kód: Vybrat vše

</blink>
Ani zamnea za <style> nepomohla :cry:

Kód: Vybrat vše

tv7.setText(Html.fromHtml("**<blink><p style=color:green;>  *&nbsp;T*</p></blink>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

TextView umi jen zakladni html tagy, neumi komplet html
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Takze neni zadny zpusob jak to "rozblikat" ? :yes:
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

nooo treba pres ten Spannable a menit to pomoci Timer, Handler, ...
Nebo to T mit jako extra TextView a menit jeho visibility
Moznosti bude vicero
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Aha, to je na me slozite. Mohl bys mi sem hodit nejaky minimal working example jak to T rozblikam nejjednodussim zpusobem ?

Dekuji
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Crusty, kdyz mi jeste pomuzes s tim blikanim "T"ecka, muzu Ti poslat za ochotu par stovek na ucet, kdyz mi ho sem das.
:rtfm:
Diky
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

no treba takto je to jednoduse, ale blika to porad, i kdyz se activita ukonci

Kód: Vybrat vše

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);
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Crusty, to vypada fajn, ale nevim, kam to mam umistit.

Posilam .xml a .java. kdybys mi to dal na to spravne misto muzes ?

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" />


    </LinearLayout>



 

</ScrollView>
.java

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.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);


    }

    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;>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));

        tv7.setText(Html.fromHtml("**<p style=color:green>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </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());
            }


        }
    }

    }
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

do onCreate() to muzes dat
pak idealne v onStart() a v onStop() to spoustet a vypinat., ted kdyz si tam das Log, tak to bude blikat ikdyz je app na pozadi
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Zkusim to cele dat do OnCreate(). Jeste ale nevim, kde je v Tvem kodu napsane, ze ma blikat prave to "T" ?
Jak to tam mam napsat ? A co mam dat do XMLka ?
Jsem fakt zacatecnik.
Diky
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

blika to se samostatnym TextView, tak si do XML pridej nove TextView ktere bude obsahovat jen to pismeno T
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

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;>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));

        tv7.setText(Html.fromHtml("**<p style=color:green>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </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());
            }


        }
    }

    }


Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

kde tam jsou hvezdicky? V layoutu je nevidim, nebo sem si jich nevsiml
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Dej hledat na strance prohlizece v me predchozi odpovedi v druhem okynku (tedy v MainActivity.java) tento radek

Kód: Vybrat vše

tv7.setText(Html.fromHtml("**<p style=color:green>  *&nbsp;T*</p>
Kdyby tam blikalo to "T*" tak to bude nas cil.
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

misto toho radku, co jsi mi naposled poslal

Kód: Vybrat vše

tv7.setText(Html.fromHtml("**<p style=color:green>  *&nbsp;T*</p>
nakopiruj toto. Meni to barvy mezi bilou a zelenou, takze to vypada, ze to blika (predpokladam bilem pozadi)

Kód: Vybrat vše

SpannableStringBuilder ssb = new SpannableStringBuilder();
        ssb.append(Html.fromHtml("**<p style=color:green>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));
        int blinkTextIndex = 6;
        ssb.setSpan(new FCS(tv7, new int[] {Color.WHITE, Color.GREEN}), blinkTextIndex, blinkTextIndex + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv7.setText(ssb);
pak si na konec MainActivity jeste vloz tuto tridu (nebo do extra souboru)

Kód: Vybrat vše

class FCS extends ForegroundColorSpan implements TimeAnimator.TimeListener {

        private TextView tv;
        private int[] colors;
        private int color;
        TimeAnimator animator;
        ArgbEvaluator evaluator;

        public FCS(TextView tv, int[] colors) {
            super(colors[0]);
            this.tv = tv;
            this.colors = colors;
            animator = new TimeAnimator();
            animator.setTimeListener(this);
            evaluator = new ArgbEvaluator();
            animator.start();
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            ds.setColor(color);
        }

        @Override
        public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
            float sin = (float) (Math.sin(Math.PI * totalTime / 1000f));
            float fraction = sin * sin;
//            float fraction = (float) (-Math.cos(2*Math.PI * totalTime / 1000f) + 1) / 2f;
            color = (int) evaluator.evaluate(fraction, colors[0], colors[1]);
            tv.invalidate();
            if (totalTime > 20000) {
                animator.end();
            }
        }
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Funguje :palec:

Premyslim, kde se funkci

Kód: Vybrat vše

public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
predavaji ty dva parametry

Kód: Vybrat vše

totalTime
a

Kód: Vybrat vše

deltaTime
?
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Crusty jak do aplikace v Andorid Studiu napisu tuto recko-matematickou formulku:
Přílohy
111.jpg
111.jpg (5.2 KiB) Zobrazeno 2199 x
Uživatelský avatar
Crusty
Robot
Příspěvky: 938
Registrován: ned 19. črc 2009 17:30:40
Typ mobilu / ROM: Redmi Note 9 Pro
Bydliště: Praha
Kontaktovat uživatele:

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od Crusty »

no treba jako obrazek to zobrazit v app? Zalezi asi ceho chces dosahnout
max2
Stálý androiďák
Příspěvky: 55
Registrován: čtv 17. úno 2022 18:15:35
Typ mobilu / ROM: flizp z 3 samsung

Re: potize s vyvojem aplikace, uzivatelsky vstup

Příspěvek od max2 »

Chtel bych psat matematicke formulky typu LaTeX do aplikace.
Obrazek se mi nehodi.
Chtel bych toto nejak napsat do Androida:

$$\frac{\eta_i(v)}{\sum_{i\in N}\eta_i(v)}$$
Odpovědět

Zpět na „Rady a tipy pro vyvoj“