CERCA
PER MODELLO
FullScreen Chatbox! :)

Utente del giorno: carotix con ben 1 Thanks ricevuti nelle ultime 24 ore
Utente della settimana: bluemask con ben 8 Thanks ricevuti negli ultimi sette giorni
Utente del mese: carotix con ben 24 Thanks ricevuti nell'ultimo mese

Visualizzazione dei risultati da 1 a 8 su 8
Discussione:

XML non salva id in R

Se questa discussione ti è stata utile, ti preghiamo di lasciare un messaggio di feedback in modo che possa essere preziosa in futuro anche per altri utenti come te!
  1. #1
    Baby Droid


    Registrato dal
    May 2014
    Messaggi
    48

    Ringraziamenti
    9
    Ringraziato 0 volte in 0 Posts
    Predefinito

    XML non salva id in R

    come da oggetto, quando da mainactivity casto non mi viene riconosciuta la referenza al codice xml che creo es.
    Button bottoncinoCarinissimo =(Button) findViewByID(R.id.stoBottoncinoNonStaInRUffa);

    adt build v22.6

  2.  
  3. #2
    Androidiani Power User L'avatar di cesco


    Registrato dal
    Sep 2010
    Località
    Bg
    Messaggi
    5,018
    Smartphone
    TYTN2,desire,desireHD, oneX

    Ringraziamenti
    54
    Ringraziato 1,346 volte in 724 Posts
    Predefinito

    occhio agli import!
    Sicuro di aver aggiunto l'import corretto, ossia, "com.tuopacchetto.R" invece di "com.android.R" ?
    Follow me on:
    <!-- Place this tag where you want the widget to render. -->
    <div class="g-person" data-width="180" data-href="//plus.google.com/113012341277613226011" data-theme="dark" data-rel="author"></div>

    <!-- Place this tag after the last widget tag. -->
    <script type="text/javascript">
    window.___gcfg = {lang: 'it'};

    (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>
    <br>
    <a class="twitter-timeline" href="https://twitter.com/xcesco89" data-widget-id="398762031488040960">Tweets di @xcesco89</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementB yId(id)){js=d.createElement(s);js.id=id;js.src=p+" ://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}} (document,"script","twitter-wjs");</script>
    Androidiani app
    Estensione Androidiani per Google Chrome

  4. #3
    Baby Droid


    Registrato dal
    May 2014
    Messaggi
    48

    Ringraziamenti
    9
    Ringraziato 0 volte in 0 Posts
    Predefinito

    Ciao Cesco
    grazie per l'interesse, dunque in main ho questi import
    package com.example.last;

    import android.support.v7.app.ActionBarActivity;
    import android.support.v7.app.ActionBar;
    import android.support.v4.app.Fragment;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.Button;
    import android.widget.EditText;
    import android.os.Build;
    mentre invece R e' nella directory last( ho usato sto nome perche' ho provato decine di volte)/gen/com.example.last/R.java

    per piacere aiutami che sto uscendo passo tra clean, build e librerie.

  5. #4
    Androidiani Power User L'avatar di cesco


    Registrato dal
    Sep 2010
    Località
    Bg
    Messaggi
    5,018
    Smartphone
    TYTN2,desire,desireHD, oneX

    Ringraziamenti
    54
    Ringraziato 1,346 volte in 724 Posts
    Predefinito

    Quote Originariamente inviato da ndrokki Visualizza il messaggio
    Ciao Cesco
    grazie per l'interesse, dunque in main ho questi import


    mentre invece R e' nella directory last( ho usato sto nome perche' ho provato decine di volte)/gen/com.example.last/R.java

    per piacere aiutami che sto uscendo passo tra clean, build e librerie.
    prova ad inserire tra gli import:

     
    1
    2
    import com.example.last.R;
    3


    Follow me on:
    <!-- Place this tag where you want the widget to render. -->
    <div class="g-person" data-width="180" data-href="//plus.google.com/113012341277613226011" data-theme="dark" data-rel="author"></div>

    <!-- Place this tag after the last widget tag. -->
    <script type="text/javascript">
    window.___gcfg = {lang: 'it'};

    (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>
    <br>
    <a class="twitter-timeline" href="https://twitter.com/xcesco89" data-widget-id="398762031488040960">Tweets di @xcesco89</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementB yId(id)){js=d.createElement(s);js.id=id;js.src=p+" ://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}} (document,"script","twitter-wjs");</script>
    Androidiani app
    Estensione Androidiani per Google Chrome

  6. #5
    Baby Droid


    Registrato dal
    May 2014
    Messaggi
    48

    Ringraziamenti
    9
    Ringraziato 0 volte in 0 Posts
    Predefinito

    grazie, no way
    anche inserendo l'import
    la linea
    EditText e=findViewById(R.id.EditText23); non viene resolved
    cliccando sulla barra a sinistra della riga eclipse mi conferma che EditText23=0 ( non ha un indirizzo esadecimale, ovvero non e' scritto in R! nonostante ho scritto
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <EditText
    android:id="@+id/EditText23"
    android:layout_width="match_parent"
    android:layout_height="358dp"
    android:hint="Text here please Ivano" />

    <Button

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Saved" />

    <Button

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

    </LinearLayout>
    ecco il main

    package com.example.last;

    import android.support.v7.app.ActionBarActivity;
    import android.support.v7.app.ActionBar;
    import android.support.v4.app.Fragment;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.Button;
    import android.widget.EditText;
    import android.os.Build;
    import com.example.last.R;

    public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction()
    .add(R.id.container, new PlaceholderFragment()).commit();
    }
    EditText e=findViewById(R.id.EditText23);
    addSaveButtonListener();

    }

    private void addSaveButtonListener() {


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
    return true;
    }
    return super.onOptionsItemSelected(item);
    }

    /**
    * A placeholder fragment containing a simple view.
    */
    public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container,
    false);
    return rootView;
    }
    }

    }
    public static final int useLogo=0x7f050003;
    public static final int withText=0x7f05000c;
    public static final int EditText23 = 0;
    }
    ...

  7. #6
    Androidiani Power User L'avatar di cesco


    Registrato dal
    Sep 2010
    Località
    Bg
    Messaggi
    5,018
    Smartphone
    TYTN2,desire,desireHD, oneX

    Ringraziamenti
    54
    Ringraziato 1,346 volte in 724 Posts
    Predefinito

    Potrebbe anche essere un errore relativo alle librerie o agli XML, quindi controlla l'Error log e vedi se da errore con qualche lib, altro proprio non mi viene in mente sinceramente O_O
    Follow me on:
    <!-- Place this tag where you want the widget to render. -->
    <div class="g-person" data-width="180" data-href="//plus.google.com/113012341277613226011" data-theme="dark" data-rel="author"></div>

    <!-- Place this tag after the last widget tag. -->
    <script type="text/javascript">
    window.___gcfg = {lang: 'it'};

    (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>
    <br>
    <a class="twitter-timeline" href="https://twitter.com/xcesco89" data-widget-id="398762031488040960">Tweets di @xcesco89</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementB yId(id)){js=d.createElement(s);js.id=id;js.src=p+" ://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}} (document,"script","twitter-wjs");</script>
    Androidiani app
    Estensione Androidiani per Google Chrome

  8. #7
    Baby Droid


    Registrato dal
    Jun 2012
    Messaggi
    4

    Ringraziamenti
    0
    Ringraziato 0 volte in 0 Posts
    Predefinito

    Ciao, probabilmente sono io che col cell non visualizzo bene il codice, ma a vederlo così l'xml sembrerebbe mal formato. Non vedo i tag di apertura dei vari elementi (relative layout textview, editview, button rcc.). Sicuro che eclipse non ti evidenzi degli errori nel file xml? Tra l'altro quando hai un errore nell'xml Eclipse non riconosce più il file r e ti da errore in ogni file java che lo usa

  9. #8
    Baby Droid


    Registrato dal
    May 2014
    Messaggi
    48

    Ringraziamenti
    9
    Ringraziato 0 volte in 0 Posts
    Predefinito

    pibraccus e cesco, grazie per l'aiuto,
    ci ho rinunciato, ho reinstallato eclipse ed ora funziona!
    grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire risposte
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Torna su
Privacy Policy