小编thu*_*mal的帖子

处理选项卡小部件时出现java.lang.UnsupportedOperationException

我正在我的应用中实现可滑动的标签.我为此实现了一个演示.以下是我的代码,

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <FrameLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" />

            <FrameLayout
                android:id="@+id/tab2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" />

            <FrameLayout
                android:id="@+id/tab3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" />

            <FrameLayout
                android:id="@+id/tab4"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" />
        </FrameLayout>

        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

</TabHost>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

public class MainActivity extends Activity implements OnTabChangeListener, OnPageChangeListener{  
    private TabHost host;  
    private ViewPager pager;  
 @Override  
 public void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

android android-tabs

13
推荐指数
1
解决办法
8738
查看次数

在Android标签中更改文本大小

我一直在标签栏中遇到文字大小的问题。下面是图片,

在此处输入图片说明

这是我的代码,

MainActivity.java

public class MainActivity extends Activity implements OnTabChangeListener, OnPageChangeListener{  
    private TabHost tabHost;  
    private ViewPager pager; 

 @Override  
 public void onCreate(Bundle savedInstanceState) {  
   super.onCreate(savedInstanceState);  
   setContentView(R.layout.activity_main);  
   tabHost = (TabHost)findViewById(android.R.id.tabhost);  
   pager = (ViewPager) findViewById(R.id.pager);  

   tabHost.setup();  
   TabWidget tabwidget=tabHost.getTabWidget();

   TabSpec spec = tabHost.newTabSpec("tab1");  
   spec.setContent(R.id.tab1);  
   spec.setIndicator("Check In");  
   tabHost.addTab(spec);  

   spec = tabHost.newTabSpec("tab2");  
   spec.setContent(R.id.tab2);  
   spec.setIndicator("Buddies");  
   tabHost.addTab(spec);  

   spec = tabHost.newTabSpec("tab3");  
   spec.setContent(R.id.tab3);  
   spec.setIndicator("Recommendation");  
   tabHost.addTab(spec); 

   spec = tabHost.newTabSpec("tab4");  
   spec.setContent(R.id.tab4);  
   spec.setIndicator("Feed");  
   tabHost.addTab(spec); 

   spec = tabHost.newTabSpec("tab5");  
   spec.setContent(R.id.tab5);  
   spec.setIndicator("Last");  
   tabHost.addTab(spec);

   pager.setAdapter(new MyPagerAdapter(this));  
   pager.setOnPageChangeListener(this);  
   tabHost.setOnTabChangedListener(this);  

 }  
    @Override  
    public void onTabChanged(String tabId){  
         int pageNumber = …
Run Code Online (Sandbox Code Playgroud)

android android-tabs

5
推荐指数
1
解决办法
3万
查看次数

获得超过8个图像搜索结果

我在我的Android应用中使用Google图片搜索API来搜索图片.它工作正常,但我只得到8个查询结果.

如何获得超过8张图像?(或者有更好的方法来搜索图像吗?)

以下是我的代码:

   public class getImagesTask extends AsyncTask<Void, Void, Void>
       {
           JSONObject json;
           ProgressDialog dialog;

           @Override
           protected void onPreExecute() {
               // TODO Auto-generated method stub
               super.onPreExecute();

               dialog = ProgressDialog.show(GoogleSearchAPIExampleActivity.this, "", "Please wait...");
           }

           @Override
           protected Void doInBackground(Void... params) {
               // TODO Auto-generated method stub

               URL url;
               try {
                   url = new URL("https://ajax.googleapis.com/ajax/services/search/images?" +
                    "v=1.0&q="+strSearch+"&rsz=8" ); //&key=ABQIAAAADxhJjHRvoeM2WF3nxP5rCBRcGWwHZ9XQzXD3SWg04vbBlJ3EWxR0b0NVPhZ4xmhQVm3uUBvvRF-VAA&userip=192.168.0.172");

               URLConnection connection = url.openConnection();
               connection.addRequestProperty("Referer", "http://technotalkative.com");

               String line;
               StringBuilder builder = new StringBuilder();
               BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
               while((line = reader.readLine()) != null) …
Run Code Online (Sandbox Code Playgroud)

android google-image-search

5
推荐指数
1
解决办法
2629
查看次数

更新Google事件时出错

我正在尝试更新谷歌日历事件,但它不能使用默认日历..我的意思是当我使用'主'默认日历它不工作这是我的代码

const USER_EVENT_TYPE='primary';
const CLASS_EVENTS='Events';
 if ($googleClient->getAccessToken())
        {
            if(!class_exists(self::CLASS_EVENTS))
            {
                $includeApplicationFiles=Mage::getBaseDir(self::LIBRARY_PATH);
                foreach (glob($includeApplicationFiles.self::INCLUDE_ALL_FILES) as $retrieveFiles)
                {
                    include $retrieveFiles;
                }
                $allCalendarEvents = $googleCalendar->events->listEvents(self::USER_EVENT_TYPE);
                foreach ($allCalendarEvents->getItems() as $getSingleEvent) {
                    if($selectedEventValue==$getSingleEvent->summary)
                    {
                        $getSingleEvent->setSummary($selectedEventValue);
                        $addEventGuests = new Google_EventAttendee();
                        $addEventGuests->setEmail($selectGuestValue);
                        $invitedGuests = array($addEventGuests);
                        $getSingleEvent->attendees = $invitedGuests;
                        $updatedEvent = $googleCalendar->events->update(self::USER_EVENT_TYPE, $getSingleEvent->getId(),$getSingleEvent);
                    }
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

有这样的错误

<br />
<b>Fatal error</b>:  Uncaught exception 'Google_ServiceException' with message 'Error calling PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/5vmet3i6mmak81utnj2p0ebv8g?key=900220817963%40developer.gserviceaccount.com: (403) Forbidden' in C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php:61
Stack trace:
#0 C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php(35): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 C:\xampp\htdocs\magento\lib\google-api-php-client\src\service\Google_ServiceResource.php(152): Google_REST::execute(Object(Google_HttpRequest))
#2 C:\xampp\htdocs\magento\lib\google-api-php-client\src\contrib\Google_CalendarService.php(591): Google_ServiceResource-&gt;__call('update', Array)
#3 …
Run Code Online (Sandbox Code Playgroud)

google-calendar-api google-api-php-client

5
推荐指数
1
解决办法
341
查看次数

如何将我的TIMESTAMP转换为magento中的UTC时间戳

我发现了许多这方面的艺术品,但没有给出适当的解决方案

我当前的系统时区是= 'asia/Kolkata'

我现在的magento时区是 'asia/shanghai'

这给了我正确的UTC时间这里系统时间'2013-06-26 15:34:00'

   $timezone = date_default_timezone_get();
   date_default_timezone_set($timezone);

   $now = Mage::getModel('core/date')->timestamp(time());
   $current_date= date('Y-m-d H:i:s');
Run Code Online (Sandbox Code Playgroud)

所以这里$ current_date = '2013-06-26 18:04:30'

但我有另一个mytimestamp ..... ex: - $ time = '2013-06-26 15:34:00';

   $scheduletime = '2013-06-26 15:19:00';
   $dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($scheduletime));
   $schedule_time = date('Y-m-d H:i:s',strtotime($scheduletime));
Run Code Online (Sandbox Code Playgroud)

所以这里$ schedule_time = '2013-06-26 23:34:00'

所以实际上我想要的是在这两次之间得到区别,它应该是:0

php timezone datetime timestamp magento

3
推荐指数
1
解决办法
1万
查看次数