我的所有片段都通过ActionBarActivity(mainActivity)控制,在mainActivity DrawerLayout中实现,并且所有子片段都通过drawerLayout的列表项单击进行推送.我面临的问题是在通过抽屉推送片段之后我想将抽屉图标更改为后退图标,ToolBar以便用户可以导航到上一个片段并处理android.R.id.home同一片段内或mainActivity内部的回调.
我使用的代码是:
MainActivity.java
public class MainActivity extends ActionBarActivity {
private DrawerLayout layoutDrawer;
private ActionBarDrawerToggle drawerToggler;
private Stack<Fragment> stack;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
stack = new Stack<Fragment>();
layoutDrawer = (DrawerLayout) findViewById(R.id.layout_drawer);
drawerToggler = new ActionBarDrawerToggle(this, layoutDrawer, toolbar,
R.string.app_name, R.string.app_name);
layoutDrawer.setDrawerListener(drawerToggler);
setUpDrawerList();
pushFragment(new FirstFragment(), true);
Session.setContext(getApplicationContext());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) { …Run Code Online (Sandbox Code Playgroud) android android-actionbar android-fragmentactivity navigation-drawer android-toolbar
在我的应用程序中我想使用Theme.NoTitleBar,但另一方面我也不想放松Android操作系统的内部主题..我在网上搜索并找到以下答案..我修改了我的styles.xml并添加了以下代码行..
内部值/ styles.xml
<style name="Theme.Default" parent="@android:style/Theme"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen"></style>
Run Code Online (Sandbox Code Playgroud)
内部值-v11/styles.xml
<style name="Theme.Default" parent="@android:style/Theme.Holo"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.Holo.NoActionBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo.NoActionBar.Fullscreen"></style>
Run Code Online (Sandbox Code Playgroud)
内部值-v14/styles.xml
<style name="Theme.Default" parent="@android:style/Theme.Holo.Light"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.Holo.Light.NoActionBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"></style>
Run Code Online (Sandbox Code Playgroud)
在Manifest文件的应用程序标记中,我添加了一个属性:
android:theme="@style/Theme.NoTitle"
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行代码时我的应用程序中的图像变得模糊..但是当我使用以下标记时:
android:theme="@android:style/Theme.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)
要么
android:theme="@android:style/Theme.Light.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)
要么
android:theme="@android:style/Theme.Black.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)
应用程序中的图像格式正确...但在这种情况下,我丢失了新Android操作系统上的所有主题..
请帮助我如何在不丢失图像和原生主题的情况下使用NoTitleBar主题..
布局代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<include
android:id="@+id/main_top_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/top_bar_title" />
<RelativeLayout
android:id="@+id/container_bar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/main_top_bar"
android:layout_marginTop="-3dp"
android:background="@drawable/tab_nav_bar" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/container_bar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/container_bar1"
android:background="@drawable/location_nav_bar" >
<TableLayout
android:id="@+id/map_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true" …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我使用Gridview创建了一个日历,在Gridview中,我在Imageview的帮助下显示日期和一些事件的可用性,为此,我创建了一个处理程序.
现在我想停止处理程序.
MainActivity.java
// inside oncreate
Handler handler = new Handler();
refreshCalendar();
// outside oncreate
public void refreshCalendar() {
calAdapter.refreshDays();
calAdapter.notifyDataSetChanged();
handler.post(calendarUpdater);
calTitle.setText(android.text.format.DateFormat.format("MMMM yyyy", cal));
}
public Runnable calendarUpdater = new Runnable() {
@Override
public void run() {
items.clear();
allData = new ArrayList<HashMap<String,String>>();
allData.clear();
allData = db.showAllEvents();
String currentDate = (String)android.text.format.DateFormat.format("MM/yyyy", cal);
for(int i=0; i<allData.size(); i++)
{
String date[] = allData.get(i).get("date").split("/");
String md[] = currentDate.split("/");
if(date[1].equals(md[0]) && date[2].equals(md[1]))
{
items.add(date[0]);
System.out.println("dates: "+date[0]);
}
}
calAdapter.setItems(items);
calAdapter.notifyDataSetChanged();
}
};
Run Code Online (Sandbox Code Playgroud)
请告诉我应该如何以及在哪里禁用此线程.
在我的应用程序中,我试图从网站复制文本并将其粘贴到我的strings.xml文件中,保存strings.xml文件后我无法在textview中使用该字符串,当我尝试清理我的项目时,我的R.java被删除了当我从strings.xml中删除该文本时,我保留了我的R.java.我想复制以下网站的文字.
http://mygogolfteetime.com/term-of-use
我的String值是:
<string name="terms_of_use">
Website Terms, Conditions, and Notices AgreementBetween Customer and GoGolf, L.P.
Welcome to the mygogolfteetime.com website (the "Website"). This Website is provided solely to assist customers in gathering tee time information, determining the availability of tee time-related goods and services, making legitimate reservations or otherwise transacting business with golf tee time suppliers, and for no other purposes. The terms "we", "us", "our" and "mygogolfteeetime.com" refer to GoGolf, L.P., a Texas limited partnership …Run Code Online (Sandbox Code Playgroud) 我想从给定的日期获得当前的周数.即如果我输入日期为01/03/2013,那么我应该得到9的周数.
请帮我找到解决方案..
谢谢..
阿布舍克..
在我的应用程序中,我创建了一个自定义列表视图,我想实现一个过滤器,以便可以根据EditText中输入的文本过滤列表.我使用BaseAdapter作为一个单独的类,我在我的主要活动中调用该类.我还在我的main活动中实现了addTextChangedListener(),我还在BaseAdapter类中实现了getFilter().但我不知道如何使用getFilter()并可以相应地过滤我的列表.在列表中,我将添加JSON URL中的值.请帮助我告诉我如何使用getFilter()来过滤我的列表.
Activity类的代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv = (ListView)findViewById(R.id.listView1);
et1 = (EditText)findViewById(R.id.editText1);
inflator = getLayoutInflater();
et1.addTextChangedListener(this);
JsonParser jParser = new JsonParser();
JSONObject json = jParser.getJSONfromUrl(url);
try
{
JSONArray explore = json.getJSONArray("explore");
for(int i=0; i<explore.length(); i++)
{
JSONObject exp = explore.getJSONObject(i);
list.add(exp.getString("username"));
}
}
catch(JSONException e)
{
e.printStackTrace();
}
srchadptr = new SearchAdapter(this, inflator, list);
lv.setAdapter(srchadptr);
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
srchadptr.getFilter().filter(s);
}
public void beforeTextChanged(CharSequence s, int start, int …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有3个活动:
1. Login
2. AsyncTask (不同类)
3. Welcome
收到所有信息后,Login Activity它移动到AsyncTask Activity.当在AsyncTask完成其移动到Welcome Activity.我想Login Activity在AsyncTask Activity完成工作后立即关闭..
我尝试使用下面的代码onPostExecite()的AsyncTask:
Login.this.finish();
但我得到一个错误:No enclosing instance of the type of Login is accessible in scope..
请告诉我如何Login Activity在完成我的工作后关闭我的AsyncTask..
提前致谢...
android ×7
baseadapter ×1
calendar ×1
filter ×1
handler ×1
java ×1
runnable ×1
string ×1
textview ×1
week-number ×1