我想复制我的android项目并使用不同的名称从相同的文件创建一个新项目.这样做的目的是让我可以拥有应用程序商店广告支持的应用程序的第二个版本.
我在这里找到了这个答案:
但是对于eclipse,我怎么能在Android Studio中做到这一点?
我创建了一个工作谷歌地图,我现在试图自动缩小,所以所有的点都适合.
当我添加:
var bounds = new google.maps.LatLngBounds();
Run Code Online (Sandbox Code Playgroud)
和
bounds.extend(point);
map.fitBounds(bounds);
Run Code Online (Sandbox Code Playgroud)
然后我得到这个错误:
Uncaught RangeError: Maximum call stack size exceeded
J.get
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous function)
Ey.(anonymous function).zoomRange_changed
Zf
J.set
(anonymous …Run Code Online (Sandbox Code Playgroud) 我有一个工具栏,我使用,并设置标题:
((ActionBarActivity)getActivity()).getSupportActionBar().setTitle("Home");
Run Code Online (Sandbox Code Playgroud)
有没有办法将颜色从黑色变为白色?
我尝试制作自己的主题并在xml中设置它,但没有骰子:
<resources>
<!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
</style>
<style name="Widget.MyApp.ActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:background">@color/primary</item>
<item name="theme">@style/ThemeOverlay.MyApp.ActionBar</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
<style name="ThemeOverlay.MyApp.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#FFFFFF</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e5e5e5"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:background="@color/primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MyApp.ActionBar">
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/statsSpin"
android:spinnerMode="dropdown"
android:textColor="#FFFFFF"/>
</android.support.v7.widget.Toolbar>
<ListView
android:id="@+id/yourStats"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="0px"
android:divider="@null"
>
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个MainDrawer to Fragment活动,它有一个导航抽屉的布局我和我的主要内容,我可以在其中加载新的碎片.我加载的一个片段是calle StatisticsTab Fragment.这个Fragment包含一个tabhost,每个tab都是它自己的listview项的片段.一旦我点击ListView项目,它加载另一个新的片段,我不再在tabHost中,我尝试使用导航器返回到我的StatisticsTab片段,我收到此错误:
03-03 10:32:06.884 24185-24185/com.beerportfolio.beerportfoliopro E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.IllegalStateException: Recursive entry to executePendingTransactions
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1439)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
at android.support.v4.app.FragmentTabHost.onAttachedToWindow(FragmentTabHost.java:283)
at android.view.View.dispatchAttachedToWindow(View.java:12307)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2457)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2464)
at android.view.ViewGroup.addViewInner(ViewGroup.java:3567)
at android.view.ViewGroup.addView(ViewGroup.java:3399)
at android.view.ViewGroup.addView(ViewGroup.java:3344)
at android.view.ViewGroup.addView(ViewGroup.java:3320)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:5789)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
如果我没有在StatisticsTab片段上点击我的任何标签,并通过navdrawer导航到另一个片段,然后返回StatisticsTab,那么它就不会FC上.也就是说,当我回到它们时,NavDrawer中的其他任何片段都没有关闭,只有带有标签的片段.
MainDrawer2:
public class MainDrawer2 extends FragmentActivity
{
private static final String EXTRA_NAV_ITEM …Run Code Online (Sandbox Code Playgroud) 我想在android studio中添加我的Android应用程序中的admob.我几乎在那里,但我得到的错误:
Namespace 'ads' not bound
Run Code Online (Sandbox Code Playgroud)
这也是我的广告xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"/>
<TextView
android:id="@+id/beerTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="20sp"
android:textStyle = "bold"
android:padding="5dip"
>
</TextView>
<ImageView android:id="@+id/image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_margin="10dip"/>
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableStatTitles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip" >
<TextView
android:id="@+id/abvTitle"
android:text="ABV"
android:gravity="center"
android:textStyle = "bold"
android:textSize="20sp"
android:layout_weight="1"
></TextView>
<TextView
android:id="@+id/IBUTitle"
android:text="IBU"
android:gravity="center"
android:textStyle = "bold"
android:textSize="20sp"
android:layout_weight="1"
></TextView>
<TextView …Run Code Online (Sandbox Code Playgroud) 我有一个带搜索图标的操作栏.单击搜索图标后,它将扩展到用户可以键入搜索的搜索栏.
问题是,当用户输入搜索时,我希望搜索栏折叠回图标,但我无法让它在我的生活中发生.
我的操作栏菜单如下所示:
<menu 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"
tools:context=".MainActivity" >
<item android:id="@+id/menu_search2"
android:actionViewClass="android.widget.SearchView"
android:title="Search"
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="always|collapseActionView|"
android:onClick="goToSearch"
/>
<item android:id="@+id/action_scan"
android:icon="@drawable/barcode"
android:onClick="scanBarcode"
android:showAsAction="ifRoom|collapseActionView"
/>
</menu>
Run Code Online (Sandbox Code Playgroud)
我的搜索活动如下:
public class Search extends Fragment implements SearchView.OnQueryTextListener, ReadJSONResult.OnArticleSelectedListener {
private ListView lv;
View v;
SearchView searchView;
private SearchView mSearchView;
private MenuItem mSearchMenuItem;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//set layout here
v = inflater.inflate(R.layout.activity_search, container, false);
setHasOptionsMenu(true);
getActivity().setTitle("Search");
//get user information
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
String userName = prefs.getString("userName", null);
String …Run Code Online (Sandbox Code Playgroud) 我试图设置我的工具栏标题:
public class StatisticsPage extends Fragment {
public StatisticsPage(){}
private FragmentTabHost mTabHost;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.statistics_pagelayout, container, false);
Spinner spinner = (Spinner) rootView.findViewById(R.id.statsSpin);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
R.array.statspage, R.layout.dropdown_item);
spinner.setAdapter(adapter);
getSupportActionBar().setTitle("My title");
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
switch (position) {
case 0:
break;
case 1:
// do whatever stuff you wanna do here
Fragment Fragment_one;
FragmentManager man= getActivity().getSupportFragmentManager();
FragmentTransaction tran …Run Code Online (Sandbox Code Playgroud) 我试图将我完成的Android应用程序上传到Android市场,我收到此错误:
You need to use a different package name because "com.example" is restricted.
Run Code Online (Sandbox Code Playgroud) 我可以像这样创建简单的json对象:
$d = array('item' => "$name" ,'rate' => "$rating");
Run Code Online (Sandbox Code Playgroud)
但是,如果我想构建一个项目数组并动态地执行它,因为我从数据库查询构建它?
更新:
让我更具体一点,我知道我必须这样做:
$jsonCode = json_encode($d);
Run Code Online (Sandbox Code Playgroud)
这将创建一个带有项目和费率字段的json对象.但是当我编码它时,我想在json数组中有多个json对象.
我想要的json明智是这样的:
[{"item":"toy","rating":"baz" },{"item":"bike","rating":"2.3" }, {"item":"juice","rating":"1.3" }]
Run Code Online (Sandbox Code Playgroud) 我有一个操作栏,将所有内容放在右上角的菜单中,用户点击该菜单并打开菜单选项.
我在使用它的每个活动上用操作栏菜单膨胀:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main2, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud)
我的main2.xml的xml是:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_searchHome"
android:orderInCategory="100"
android:showAsAction="never"
android:title="Seach"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
我的问题是我在xml中的项目中放了一个onclick,如果是这样,我在哪里放置它调用的onclick方法?我是否需要将其添加到我启动此操作栏的每个活动中?
android ×7
admob ×1
android-xml ×1
build.gradle ×1
forceclose ×1
google-maps ×1
google-play ×1
gradle ×1
json ×1
php ×1