Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Epilef Ordep

não consigo salvar o estado da fragment quando giro ou saio dela

Recommended Posts

uma ajuda por favor estou, tentando salvar o estado de um fragment quando saio dele, já coloquei setRetainInstance(true), onSaveInstanceState , mais quando volto para fragment ou quando giro ele os valores que modifiquei não permanecem, alguem sabe outra forma

 

 

public class FragmentDebug extends Fragment {
ImageView first_country_img;
ImageView secound_country_img;
TextView first_initials;
TextView first_country_text;
TextView second_initials;
TextView secound_country_text;
EditText first_country_edit;
EditText second_country_edit;
View headerLayout;

int clicouNoPrimeiro = 0;
int clicouNoSegundo = 0;

int percentual_taxa = 0;

private Moeda moeda_primeiro_pais;
private Moeda moeda_segundo_pais;

private String flagSiglaPais1 = "brl";
private String flagSiglaPais2 = "eur";
private ICreditoBo iCreditoBo;

private IUsuarioDao iUsuarioBo;

private TextView nomeUsuario;
private TextView creditosUsuario;
private ImageView fotoUsuario;
private ProfilePictureView profilePictureView;
private SharedPreferences preferences;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_conversor, null);

first_country_text = (TextView) view.findViewById(R.id.first_country_text);
secound_country_text = (TextView) view.findViewById(R.id.second_country_text);

first_initials = (TextView) view.findViewById(R.id.first_initials);
second_initials = (TextView) view.findViewById(R.id.second_initials);

first_country_img = (ImageView) view.findViewById(R.id.first_country_img);
secound_country_img = (ImageView) view.findViewById(R.id.secound_country_img);

first_country_edit = (EditText) view.findViewById(R.id.first_country_edit);
second_country_edit = (EditText) view.findViewById(R.id.second_country_edit);

view.findViewById(R.id.trocar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trocar();
}
});

int resBandeira = getResources().getIdentifier("ic_" + flagSiglaPais1, "drawable", getActivity().getPackageName());
int resPais = getResources().getIdentifier(flagSiglaPais1, "string", getActivity().getPackageName());
first_country_text.setText(resPais);
first_initials.setText(flagSiglaPais1);
first_country_img.setImageResource(resBandeira);
first_country_edit.setText("1,0");
IMoedaBo iMoedaBo = new MoedaBo(getActivity());
Moeda m = iMoedaBo.findOne("UPPER(sigla) = UPPER(?)", new String[]{flagSiglaPais2});
ConversaoMoeda conversaoMoeda = new ConversaoMoeda(String.valueOf(m.getCotacao()), "1");
conversaoMoeda.setTaxa_itermediacao(percentual_taxa);
int resBandeira2 = getResources().getIdentifier("ic_" + flagSiglaPais2, "drawable", getActivity().getPackageName());
secound_country_text.setText(m.getPais());
second_initials.setText(m.getSigla());
secound_country_img.setImageResource(resBandeira2);
double resultado = Double.parseDouble(conversaoMoeda.retornoDeX());
second_country_edit.setText(new DecimalFormat("0.00").format(resultado));
//System.out.println(m.getSigla());
return view;
}



private String flagTrocar = "normal";
private void trocar(){
String editTextFirst = first_country_edit.getText().toString();
int qtdFirst = 0;
for (int i = 0; i < editTextFirst.length(); i++){
if (editTextFirst.charAt(i) == '.') {
qtdFirst++;
}
}
String first_edit = "0";
if(qtdFirst > 1) {
first_edit = first_country_edit.getText().toString().replace(".", "").replace(",",".");
}else {
first_edit = first_country_edit.getText().toString().replace(",",".");
}

first_edit = (first_edit.equals("") ? "0" : first_edit);

clicouNoPrimeiro = 0;
clicouNoSegundo = 0;
Moeda moeda1 = new Moeda(
first_initials.getText().toString(),
first_country_text.getText().toString(),
Double.valueOf(first_edit)
);

String editText = second_country_edit.getText().toString();
int qtd = 0;
for (int i = 0; i < editText.length(); i++){
if (editText.charAt(i) == '.') {
qtd++;
}
}

String second_edit = "0";
if(qtdFirst > 1) {
second_edit = second_country_edit.getText().toString().replace(".", "").replace(",",".");
}else {
second_edit = second_country_edit.getText().toString().replace(",",".");
}

second_edit = (second_edit.equals("") ? "0" : second_edit);

///Log.i("first",first_country_edit.getText().toString());
Moeda moeda2 = new Moeda(
second_initials.getText().toString(),
secound_country_text.getText().toString(),
Double.valueOf(second_edit)
);

////Log.i("secound",second_country_edit.getText().toString());
secound_country_text.setText(moeda1.getPais());
second_initials.setText(moeda1.getSigla());
int resBandeira1 = getResources().getIdentifier("ic_" + moeda1.getSigla().toLowerCase(), "drawable", getActivity().getPackageName());
secound_country_img.setImageResource(resBandeira1);
second_country_edit.setText(new DecimalFormat("0.00").format(moeda1.getCotacao()));

first_country_text.setText(moeda2.getPais());
first_initials.setText(moeda2.getSigla());
int resBandeira2 = getResources().getIdentifier("ic_" + moeda2.getSigla().toLowerCase(), "drawable", getActivity().getPackageName());
first_country_img.setImageResource(resBandeira2);
first_country_edit.setText(new DecimalFormat("0.00").format((moeda2.getCotacao())));

if(flagTrocar == "normal"){
flagTrocar = "trocou";
}else{
flagTrocar = "normal";
}
}
}

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por ILR master
      Pessoal, pergunta bem simples. Abaixo tenho o seguinte código:
       
      <script>
      function alerta()
      {
        if (window.confirm("Você realmente quer sair?")) {
          window.open("sair.html");
      }
      }
      </script>
       
      Funciona perfeitamente, só que está abrindo em outra janela e quero que abra na mesma janela.
       
      Alguém pode me ajudar?
    • Por Jack Oliveira
      Ola pessoal boa tarde
      estou tentando fazer um texto se mover dentro do input porem nao esta dando resultado que preciso
       
      Este é o codigo 
      <script type="text/javascript"> $(document).ready(function () { var frases = [{ 'elemento': $('input[name=search_string]'), 'frases': ["O que você está procurando?", "Buscar por: Academia, Barbearia, Churrascaria, Decoração, Escola, Farmácia, Gráfica, Imobiliaria, Lanchonete, Mecânica, Odontologia, Pizzaria...", "Faça sua busca por segmentos aqui.", "São mais de 3mil empresas para serem exploradas."] }]; animaInput(frases); }); </script>  
    • Por Rengavitp
      Boa noite pessoal!
       
      Estou fazendo um projeto web com spring boot e é a primeira vez que lido com imagens. Minha idéia é salvar imagens em uma pasta e depois recuperar essa imagem e mostrar, mas o problema que estou enfrentando é o seguinte, seu eu envio para o src do projeto na pasta imagens, eu até consigo acessar as imagens, mas preciso atualizar o projeto na IDE (isso vai acontecer em produção?) eu tentei salvar em uma pasta fora do source do projeto mas ai não consigo acessar. como devo fazer? fiz várias pesquisas, mas nenhuma me ajudou.
       
      Desde já agradeço.
    • Por Rengavitp
      Bom dia pessoal!

      Estou com o seguinte problema, tenho uma aplicação que funciona perfeitamente rodando na minha IDE (Spring Tool Suite) mas ao gerar o arquivo war e subir a aplicação no tom cat ele não funciona, mas apenas erro 404, abri o war e todos os arquivo estão lá, já tem seguir tudo quando e tutorial com problemas semelhantes mas nenhum resolveu. Abaixo mais informações,.

      Versão do java na aplicacao 11
      Versão do jva no servidor 11
      Versão do tomcat no servidor 8.5.55
       
      minha classe principal
      package br.com.masterplastfitas; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication public class MasterApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(MasterApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(MasterApplication.class); } } meu pom.xml
      <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.2</version> <relativePath /> <!-- lookup parent from repository --> </parent> <groupId>masterplast</groupId> <artifactId>Master</artifactId> <version>2.0</version> <packaging>war</packaging> <name>Master</name> <description>Aplicação web </description> <properties> <java.version>11</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity5</artifactId> </dependency> <dependency> <groupId>org.mindrot</groupId> <artifactId>jbcrypt</artifactId> <version>0.4</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.0</version> </dependency> </dependencies> <build> <plugins> <!-- <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> --> </plugins> </build> </project>  
    • Por Stephhany909
      While trying to persist an object with an attribute of type Point, defined as follows:
       
      @Entity @Table(name = "event") public class Event { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private long id; @Column(columnDefinition = "POINT") private Point coordinate; } I'm getting the error Data truncation: Cannot get geometry object from data you send to the GEOMETRY field.
      The corresponding database table is defined as follows:
       
      create table event ( id bigint not null auto_increment, coordinate POINT, primary key (id) ) engine= InnoDB; What am I missing?
       
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.